Hallo leute,
ich bräuchte mal die Hilfe von Arduino-Könnern...
Ich habe mir ein jD-IOBoard gekaufthttp://www.jdrones.com/jDoc/wiki:code_ioboard
und würde es gerne über einen Empfängerausgang ansteuern.
es sind ein paar Arduino-Blink-Codes dabei.
Ich habe es schon geschafft den Code so zu reduzieren, das es so Blinkt wie ich es will
(habe einfach ein paar sachen gelöscht)
Ausgang 1 soll dauernd leuchten.
Ausgang 6 ist aus<-wird nicht benutzt
digitalWrite(8, HIGH); // set the LED on
digitalWrite(2, LOW); // set the LED off
Hier mal der Code:
nun gut....
jetzt hätte ich gerne, das ich an der Fernsteuerung einen Taster betätige und das kurze Blinkprogramm startet.
Wenn der durchgang fertig ist soll alles wieder aus sein, bis ich den Taster wieder kurz betätige.
Es sind Digitale und Analoge Eingänge frei, wo ich das Signal vom Empfänger einspeisen könnte.
Bei mir happert es nur, wie ich sowas in den Code mit reinschreiben soll :-(
Kann mir da jemand helfen????
....ein weiterer Traum von mir währe,
Taster an der Steuerung kurz drücken--> obige Blinkerei einmalig
Taster an der Steuerung länger drücken(ca. 2sek) --> obige Blinkerei durchlaufend ausführen, bis Taster wieder gedrückt wird.
....weis schon....sind halt Träume....aber vieleicht kann mir jemand so ein Code schnipseln
Grüße,
Markus
ich bräuchte mal die Hilfe von Arduino-Könnern...
Ich habe mir ein jD-IOBoard gekaufthttp://www.jdrones.com/jDoc/wiki:code_ioboard
und würde es gerne über einen Empfängerausgang ansteuern.
es sind ein paar Arduino-Blink-Codes dabei.
Ich habe es schon geschafft den Code so zu reduzieren, das es so Blinkt wie ich es will
(habe einfach ein paar sachen gelöscht)
Ausgang 1 soll dauernd leuchten.
Ausgang 6 ist aus<-wird nicht benutzt
digitalWrite(8, HIGH); // set the LED on
digitalWrite(2, LOW); // set the LED off
Hier mal der Code:
/**********************************************************/
//
//
//////////////////////////////////////////////////////////////////////////
//**Description:*
//*
//**This*is*example*Arduino*sketch*on*how*to*use*jD-IOBoard.
//**LED*Driver*board*that*listens*I2C*commands*and*changes*patterns*accordingly.
//
//**If*you*use,*redistribute*this*please*mention*original*source.
//
//**jD-IOBoard*pinouts
//
//*************S*M*M*G*******R*T*R
//*********5*5*C*O*I*N*D*D*D*X*X*S
//*********V*V*K*S*S*D*7*6*5*1*1*T
//*********|*|*|*|*|*|*|*|*|*|*|*|
//******+----------------------------+
//******|O*O*O*O*O*O*O*O*O*O*O*O*O***|
//*O1*-*|O*O***|*|*|****************O|*_*DTS*
//*O2*-*|O*O***3*2*1****************O|*-*RX**F
//*O3*-*|O*O***1*1*1****************O|*-*TX**T
//*O4*-*|O*O***D*D*D****************O|*-*5V**D
//*O5*-*|O*O************************O|*_*CTS*I
//*O6*-*|O*O*O*O*O*O*O*O***O*O*O*O**O|*-*GND
//******+----------------------------+
//*******|***|*|*|*|*|*|***|*|*|*|
//*******C***G*5*A*A*A*A***S*S*5*G
//*******O***N*V*0*1*2*3***D*C*V*N
//*******M***D*************A*L***D
//
//*More*information,*check*http://www.jdrones.com/jDoc
//
/******************************************************************************/
///////////////////////////
//*Global*includes
///////////////////////////
//*Global*defines*
#define*VER*"v1.0"
#define*O1*8******// High power Output 1
#define*O2*9******// High power Output 2, PWM
#define*O3*10*****// High power Output 3, PWM
#define*O4*4******// High power Output 4
#define*O5*3******// High power Output 5, PWM
#define*O6*2******// High power Output 6
#define*EN**1*****// Enable value
#define*DI**0*****// Disable value
#define*Circle_Dly*1000
#define*ledPin*13*****// Heartbeat LED if any
#define*LOOPTIME**50**// Main loop time for heartbeat
#define*BAUD*115200****// Serial speed
///////////////////////////
//*Global*variables
int counter = 0; // General counter
byte ioOut = 0; // Blinker output position
byte ioStat = LOW; // Blinker last status
byte ioCounter = 0; // Blinker count
int Out[] = {9,10,4,3}; // Output I/O pin array
long preMillis;
long curMillis;
long delMillis = 500;
//*LED*patterns
byte flight_patt[10][16] = {
**{*0,0,0,0,0,0,0,0*,0,0,0,0,0,0,0,0**},****// 0
**{*1,1,1,1,0,0,0,0*,1,1,1,1,0,0,0,0**},****// 1
**{*1,1,1,1,1,0,0,0*,0,0,0,0,0,1,0,0**},****// 2
**{*1,1,0,0,1,1,0,0*,1,1,0,0,1,1,0,0**},****// 3
**{*1,0,0,0,1,0,0,0*,1,0,0,0,1,0,0,0**},****// 4
**{*1,0,1,0,1,0,1,0*,1,0,1,0,0,0,0,0**},****// 5
**{*1,0,1,0,1,0,1,0*,1,0,1,0,1,0,1,0**},****// 6
**{*1,0,1,0,0,0,0,0*,1,0,1,0,0,0,0,0**},****// 7
**{*0,0,0,0,0,0,0,0*,0,0,0,0,0,0,0,0**},****// 8
**{*1,0,0,0,0,0,0,0*,1,0,0,0,0,0,0,0**}};***// 9
byte patt_pos;
byte patt;
//byte*debug*=*1;******//*debug*level
///////////////////////////
//*Setup*
void setup() {
**Serial.begin(BAUD);
**
**// Initializing output pins
**for(int looper = 0; looper <= 5; looper++) {
****pinMode(Out[looper],OUTPUT);
**}
**// Initializing general pattern
**patt_pos*=*0;
**patt*=*0;
**
**delay(10);
}
*
///////////////////////////
//*Main*program
void loop() {
**
***Serial.println("Begin of MainLoop");
*digitalWrite(8, HIGH); // set the LED on
*digitalWrite(2, LOW); // set the LED off
*
***delay(3000);
*****// NightRider effect and Chasers
***LEDRider(100,2);
***LEDChaser(50,*3);
***LEDChaser(25,*5);
***
***delay(10);
*
*
***
***// Final blinks after we start everything again.
***for(int loopy = 0; loopy <= 5; loopy++) {
****AllOn();
****delay(20);
****AllOff();
****delay(50);
***}*
****
delay(1);
***}
///////////////////////////
//*Global*functions
//*Blink*output*per*output*with*a*speeding*flash*speed*until*fully*lit.
//*Delay*X*as*time*to*wait*until*next*output*starts,*filling*direction*Y
void LEDWasp(int dly, int dir) {
*Serial.println("LEDWasp");
*counter*=*0;*
*int ledPos = 0;
*int looper;
*int looperdly = 35;
*if(dir == 1) ledPos = 5;
*while(counter <= 5) {
**for(looper = 255; looper >= 0; looper = looper - looperdly) {
***if(looper >= 201) looperdly = 35; // Checking and changing speed of delays
***if(looper <= 200) looperdly = 15;
***if(looper <= 150) looperdly = 10;
***if(looper <= 100) looperdly = 8;
***if(looper <= 50) looperdly = 5;
***if(looper <= 20) looperdly = 2;
***
***digitalWrite(Out[ledPos],EN);
***delay(looper);
***digitalWrite(Out[ledPos],DI);
***delay(looper);
**}
**digitalWrite(Out[ledPos],EN);
**
**if(dir) {
****ledPos--;
**}*else ledPos++;
**
**delay(dly);
**looperdly*=*35;
**counter++;**
*}**
}
//*Clears*all*outputs*with*delay*X*from*directioin*Y
void LEDClear(int dly, int dir) {
*Serial.println("LEDClear");
*if(dir == 0)
***for(int looper = 0; looper <= 5; looper++) {
****digitalWrite(Out[looper], DI);
****delay(dly);
***}*
*if(dir == 1)
***for(int looper = 5; looper >= 0; looper--) {
****digitalWrite(Out[looper], DI);
****delay(dly);
***}*
}
//*Fills*all*outputs*with*delay*X*from*direction*Y
void LEDFill(int dly, int dir) {
**Serial.println("LEDFill");
**if(dir == 0)
***for(int looper = 0; looper <= 5; looper++) {
****digitalWrite(Out[looper], EN);
****delay(dly);
***}*
*if(dir == 1)
***for(int looper = 5; looper >= 0; looper--) {
****digitalWrite(Out[looper], EN);
****delay(dly);
***}*
}
//*Blinks*all*outputs*with*delay*of*X*and*repeast*Y*times
void LEDFullBlinker(int dly, int maxcount) {
**Serial.println("LEDFullBlinker");
**counter*=*0;
**while(counter <= maxcount) {
***AllOn();
***delay(dly);
***AllOff();
***delay(dly);
***counter++;
**}***
}
**
**
//*KnightRider*effect*with*small*delays
//*One*output*is*active*at*time,*running*up*and*down
void LEDRider(int dly, int maxcount) {
**Serial.print("LEDRider");
**counter*=*0;
**int ledPos = -1;
**byte dir = 1;
**
**while(counter <= maxcount) {
***for(int looper = 0; looper <= 10; looper++) {
*****if(dir == 0) {
*******ledPos*--;
*****}*else ledPos ++;
*
*****if(dir == 0 && ledPos == 0) dir = 1;
*****if(dir == 1 && ledPos == 5) dir = 0;
*****
*****digitalWrite(Out[ledPos],EN);
*****delay(dly);
*****digitalWrite(Out[ledPos],DI);
***}*
***counter++;
**}
}
//*Up/Down*LED*Chaser*effect.*Start*from*O1*->*O6*and*then*back*to*O6*->*O1
void LEDChaser(int dly, int maxcount) {
**Serial.println("LEDChaser");
**counter*=*0;
**int looper;
**
**while(counter <= maxcount) {
***for (looper = 0; looper <= 5; looper++) {
****digitalWrite(Out[looper], EN);
****delay(dly);
***}
***for (looper = 0; looper <= 5; looper++) {
****digitalWrite(Out[looper], DI);
****delay(dly);
***}*
***counter*++;*
**}
}
//*PWM*diving*from*3*PWM*output*pins*with*optional*extra*effects
void LEDPwm(int maxcount, byte extraEffect) {
***Serial.println("LEDPwm");
***
***int pwmout = 31;
***byte dir = 1;
***counter*=*0;
**
****while(counter <= maxcount - 1) {
*****if(dir == 0) pwmout --;
*****if(dir == 1) pwmout ++;
*****if(pwmout <= 30 && dir == 0) counter ++;
*****if(pwmout >= 255) dir = 0;
*****if(pwmout <= 30) dir = 1;
*****analogWrite(O2, pwmout);
*****analogWrite(O3, pwmout);
*****analogWrite(O5, pwmout);
*****
*****if(extraEffect == 1) CheckBlink(15);
*****if(extraEffect == 2) CheckBlink(30);
*****if(extraEffect == 3) CheckBlink(10);
*****
*****delay(2);
***}***
}
//*Extra*blinks*used*during*PWM*outputs*tests
void CheckBlink(int dly) {
***int OutPort;
***delMillis*=*dly;
***
***if(ioOut == 0) OutPort = Out[0];
***if(ioOut == 1) OutPort = Out[3];
***if(ioOut == 2) OutPort = Out[5];
**
***curMillis*=*millis();
***if(curMillis - preMillis > delMillis) {
*****preMillis*=*curMillis;
*****if(ioStat == LOW) {
******digitalWrite(OutPort, EN);
******ioStat*=*HIGH;
*****}*else {
******digitalWrite(OutPort, DI);
******ioStat*=*LOW;
*****}
*****
*****ioCounter++;
*****
*****if(ioCounter >= 10){
******ioCounter*=*0;
******ioOut++;*
*****}
*****
*****if(ioOut >= 3) ioOut = 0;
***}**
}
//*Switch*all*outputs*ON
void AllOn() {
**Serial.println("AllOn");
***for(int looper = 0; looper <= 5; looper++) {
****digitalWrite(Out[looper],EN);
**}**
}
//*Switch*all*outputs*OFF
void AllOff() {
**Serial.println("AllOff");
***for(int looper = 0; looper <= 5; looper++) {
****digitalWrite(Out[looper],DI);
**}**
}
//
//
//////////////////////////////////////////////////////////////////////////
//**Description:*
//*
//**This*is*example*Arduino*sketch*on*how*to*use*jD-IOBoard.
//**LED*Driver*board*that*listens*I2C*commands*and*changes*patterns*accordingly.
//
//**If*you*use,*redistribute*this*please*mention*original*source.
//
//**jD-IOBoard*pinouts
//
//*************S*M*M*G*******R*T*R
//*********5*5*C*O*I*N*D*D*D*X*X*S
//*********V*V*K*S*S*D*7*6*5*1*1*T
//*********|*|*|*|*|*|*|*|*|*|*|*|
//******+----------------------------+
//******|O*O*O*O*O*O*O*O*O*O*O*O*O***|
//*O1*-*|O*O***|*|*|****************O|*_*DTS*
//*O2*-*|O*O***3*2*1****************O|*-*RX**F
//*O3*-*|O*O***1*1*1****************O|*-*TX**T
//*O4*-*|O*O***D*D*D****************O|*-*5V**D
//*O5*-*|O*O************************O|*_*CTS*I
//*O6*-*|O*O*O*O*O*O*O*O***O*O*O*O**O|*-*GND
//******+----------------------------+
//*******|***|*|*|*|*|*|***|*|*|*|
//*******C***G*5*A*A*A*A***S*S*5*G
//*******O***N*V*0*1*2*3***D*C*V*N
//*******M***D*************A*L***D
//
//*More*information,*check*http://www.jdrones.com/jDoc
//
/******************************************************************************/
///////////////////////////
//*Global*includes
///////////////////////////
//*Global*defines*
#define*VER*"v1.0"
#define*O1*8******// High power Output 1
#define*O2*9******// High power Output 2, PWM
#define*O3*10*****// High power Output 3, PWM
#define*O4*4******// High power Output 4
#define*O5*3******// High power Output 5, PWM
#define*O6*2******// High power Output 6
#define*EN**1*****// Enable value
#define*DI**0*****// Disable value
#define*Circle_Dly*1000
#define*ledPin*13*****// Heartbeat LED if any
#define*LOOPTIME**50**// Main loop time for heartbeat
#define*BAUD*115200****// Serial speed
///////////////////////////
//*Global*variables
int counter = 0; // General counter
byte ioOut = 0; // Blinker output position
byte ioStat = LOW; // Blinker last status
byte ioCounter = 0; // Blinker count
int Out[] = {9,10,4,3}; // Output I/O pin array
long preMillis;
long curMillis;
long delMillis = 500;
//*LED*patterns
byte flight_patt[10][16] = {
**{*0,0,0,0,0,0,0,0*,0,0,0,0,0,0,0,0**},****// 0
**{*1,1,1,1,0,0,0,0*,1,1,1,1,0,0,0,0**},****// 1
**{*1,1,1,1,1,0,0,0*,0,0,0,0,0,1,0,0**},****// 2
**{*1,1,0,0,1,1,0,0*,1,1,0,0,1,1,0,0**},****// 3
**{*1,0,0,0,1,0,0,0*,1,0,0,0,1,0,0,0**},****// 4
**{*1,0,1,0,1,0,1,0*,1,0,1,0,0,0,0,0**},****// 5
**{*1,0,1,0,1,0,1,0*,1,0,1,0,1,0,1,0**},****// 6
**{*1,0,1,0,0,0,0,0*,1,0,1,0,0,0,0,0**},****// 7
**{*0,0,0,0,0,0,0,0*,0,0,0,0,0,0,0,0**},****// 8
**{*1,0,0,0,0,0,0,0*,1,0,0,0,0,0,0,0**}};***// 9
byte patt_pos;
byte patt;
//byte*debug*=*1;******//*debug*level
///////////////////////////
//*Setup*
void setup() {
**Serial.begin(BAUD);
**
**// Initializing output pins
**for(int looper = 0; looper <= 5; looper++) {
****pinMode(Out[looper],OUTPUT);
**}
**// Initializing general pattern
**patt_pos*=*0;
**patt*=*0;
**
**delay(10);
}
*
///////////////////////////
//*Main*program
void loop() {
**
***Serial.println("Begin of MainLoop");
*digitalWrite(8, HIGH); // set the LED on
*digitalWrite(2, LOW); // set the LED off
*
***delay(3000);
*****// NightRider effect and Chasers
***LEDRider(100,2);
***LEDChaser(50,*3);
***LEDChaser(25,*5);
***
***delay(10);
*
*
***
***// Final blinks after we start everything again.
***for(int loopy = 0; loopy <= 5; loopy++) {
****AllOn();
****delay(20);
****AllOff();
****delay(50);
***}*
****
delay(1);
***}
///////////////////////////
//*Global*functions
//*Blink*output*per*output*with*a*speeding*flash*speed*until*fully*lit.
//*Delay*X*as*time*to*wait*until*next*output*starts,*filling*direction*Y
void LEDWasp(int dly, int dir) {
*Serial.println("LEDWasp");
*counter*=*0;*
*int ledPos = 0;
*int looper;
*int looperdly = 35;
*if(dir == 1) ledPos = 5;
*while(counter <= 5) {
**for(looper = 255; looper >= 0; looper = looper - looperdly) {
***if(looper >= 201) looperdly = 35; // Checking and changing speed of delays
***if(looper <= 200) looperdly = 15;
***if(looper <= 150) looperdly = 10;
***if(looper <= 100) looperdly = 8;
***if(looper <= 50) looperdly = 5;
***if(looper <= 20) looperdly = 2;
***
***digitalWrite(Out[ledPos],EN);
***delay(looper);
***digitalWrite(Out[ledPos],DI);
***delay(looper);
**}
**digitalWrite(Out[ledPos],EN);
**
**if(dir) {
****ledPos--;
**}*else ledPos++;
**
**delay(dly);
**looperdly*=*35;
**counter++;**
*}**
}
//*Clears*all*outputs*with*delay*X*from*directioin*Y
void LEDClear(int dly, int dir) {
*Serial.println("LEDClear");
*if(dir == 0)
***for(int looper = 0; looper <= 5; looper++) {
****digitalWrite(Out[looper], DI);
****delay(dly);
***}*
*if(dir == 1)
***for(int looper = 5; looper >= 0; looper--) {
****digitalWrite(Out[looper], DI);
****delay(dly);
***}*
}
//*Fills*all*outputs*with*delay*X*from*direction*Y
void LEDFill(int dly, int dir) {
**Serial.println("LEDFill");
**if(dir == 0)
***for(int looper = 0; looper <= 5; looper++) {
****digitalWrite(Out[looper], EN);
****delay(dly);
***}*
*if(dir == 1)
***for(int looper = 5; looper >= 0; looper--) {
****digitalWrite(Out[looper], EN);
****delay(dly);
***}*
}
//*Blinks*all*outputs*with*delay*of*X*and*repeast*Y*times
void LEDFullBlinker(int dly, int maxcount) {
**Serial.println("LEDFullBlinker");
**counter*=*0;
**while(counter <= maxcount) {
***AllOn();
***delay(dly);
***AllOff();
***delay(dly);
***counter++;
**}***
}
**
**
//*KnightRider*effect*with*small*delays
//*One*output*is*active*at*time,*running*up*and*down
void LEDRider(int dly, int maxcount) {
**Serial.print("LEDRider");
**counter*=*0;
**int ledPos = -1;
**byte dir = 1;
**
**while(counter <= maxcount) {
***for(int looper = 0; looper <= 10; looper++) {
*****if(dir == 0) {
*******ledPos*--;
*****}*else ledPos ++;
*
*****if(dir == 0 && ledPos == 0) dir = 1;
*****if(dir == 1 && ledPos == 5) dir = 0;
*****
*****digitalWrite(Out[ledPos],EN);
*****delay(dly);
*****digitalWrite(Out[ledPos],DI);
***}*
***counter++;
**}
}
//*Up/Down*LED*Chaser*effect.*Start*from*O1*->*O6*and*then*back*to*O6*->*O1
void LEDChaser(int dly, int maxcount) {
**Serial.println("LEDChaser");
**counter*=*0;
**int looper;
**
**while(counter <= maxcount) {
***for (looper = 0; looper <= 5; looper++) {
****digitalWrite(Out[looper], EN);
****delay(dly);
***}
***for (looper = 0; looper <= 5; looper++) {
****digitalWrite(Out[looper], DI);
****delay(dly);
***}*
***counter*++;*
**}
}
//*PWM*diving*from*3*PWM*output*pins*with*optional*extra*effects
void LEDPwm(int maxcount, byte extraEffect) {
***Serial.println("LEDPwm");
***
***int pwmout = 31;
***byte dir = 1;
***counter*=*0;
**
****while(counter <= maxcount - 1) {
*****if(dir == 0) pwmout --;
*****if(dir == 1) pwmout ++;
*****if(pwmout <= 30 && dir == 0) counter ++;
*****if(pwmout >= 255) dir = 0;
*****if(pwmout <= 30) dir = 1;
*****analogWrite(O2, pwmout);
*****analogWrite(O3, pwmout);
*****analogWrite(O5, pwmout);
*****
*****if(extraEffect == 1) CheckBlink(15);
*****if(extraEffect == 2) CheckBlink(30);
*****if(extraEffect == 3) CheckBlink(10);
*****
*****delay(2);
***}***
}
//*Extra*blinks*used*during*PWM*outputs*tests
void CheckBlink(int dly) {
***int OutPort;
***delMillis*=*dly;
***
***if(ioOut == 0) OutPort = Out[0];
***if(ioOut == 1) OutPort = Out[3];
***if(ioOut == 2) OutPort = Out[5];
**
***curMillis*=*millis();
***if(curMillis - preMillis > delMillis) {
*****preMillis*=*curMillis;
*****if(ioStat == LOW) {
******digitalWrite(OutPort, EN);
******ioStat*=*HIGH;
*****}*else {
******digitalWrite(OutPort, DI);
******ioStat*=*LOW;
*****}
*****
*****ioCounter++;
*****
*****if(ioCounter >= 10){
******ioCounter*=*0;
******ioOut++;*
*****}
*****
*****if(ioOut >= 3) ioOut = 0;
***}**
}
//*Switch*all*outputs*ON
void AllOn() {
**Serial.println("AllOn");
***for(int looper = 0; looper <= 5; looper++) {
****digitalWrite(Out[looper],EN);
**}**
}
//*Switch*all*outputs*OFF
void AllOff() {
**Serial.println("AllOff");
***for(int looper = 0; looper <= 5; looper++) {
****digitalWrite(Out[looper],DI);
**}**
}
jetzt hätte ich gerne, das ich an der Fernsteuerung einen Taster betätige und das kurze Blinkprogramm startet.
Wenn der durchgang fertig ist soll alles wieder aus sein, bis ich den Taster wieder kurz betätige.
Es sind Digitale und Analoge Eingänge frei, wo ich das Signal vom Empfänger einspeisen könnte.
Bei mir happert es nur, wie ich sowas in den Code mit reinschreiben soll :-(
Kann mir da jemand helfen????
....ein weiterer Traum von mir währe,
Taster an der Steuerung kurz drücken--> obige Blinkerei einmalig
Taster an der Steuerung länger drücken(ca. 2sek) --> obige Blinkerei durchlaufend ausführen, bis Taster wieder gedrückt wird.
....weis schon....sind halt Träume....aber vieleicht kann mir jemand so ein Code schnipseln
Grüße,
Markus