Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Arduino - Remote control (RF-TX)
Evo Makso probaj ovo :

Ovde mozes dodavati jos tastera samo u array byte taster[] dodas pin na koji je vezan taster i u array int command[numButtons] dodas komandu za taj pin i ne moras nista vise menjati u kodu.... Ovo ti je kod za transmit a na drugoj strani samo citaj komande i na osnovu njih izvrsavaj dalje radnje...
Code:
int LED = 12;
byte taster[] = {8,9};                   // ovde dodas pinove za druge tastere ako ti zatreba
#define numButtons sizeof(taster)        //array size -> ovde definisemo koliko imas tastera
int command[numButtons] = {1111,2222};   // ovde unosis komande za tastere
boolean flag = false;

void setup() {
pinMode(LED, OUTPUT);
 for(int i=0;i<numButtons;i++)
   pinMode(taster[i], INPUT);
Serial.begin(9600);
}

void loop() {
 flag=false;
 for(int i=0; i<numButtons; i++){  // prolaz kroz buttone
   int tasterTest = 0;             // variable za debounce
   digitalWrite(LED,LOW);          // gasimo led kad taster nije pritisnut
   while (digitalRead (taster[i]) == HIGH && flag==false){  // vrtimo petlju dok god je jedan od tastera pritisnut i dok nije podignut flag
     tasterTest++;                          
     if(tasterTest > 3){           // proveravamo debounce
       Serial.println(command[i]); // saljemo komandu
       digitalWrite(LED, HIGH);    // palimo led da je taster pritisnut
       flag=true;                  // podizemo flag da bi napustili for petlju da ne vrti sve mogucnosti nego da krene ponovo
       delay(500);                 // ovaj delay trenutno nam "glumi" interapt znaci svaki cca pola sekunde idu komande zaredom ako
     }                             // drzimo taster stalno pritisnut. Ovaj delay sam stavio samo zbog toga da damo dovoljno vremena wifi modulima da pravilno izkomuniciraju.
   }                              
   if(flag) break;                 // zapocinjemo for petlju ponovo
 }
}

Ovo ti je bez interapta koji za ovakav jednostavan primer i nije potreban kad program naraste do granica potrebe za njim onda cemo ga i implemetirati...
Reply


Messages In This Thread
Arduino - Remote control (RF-TX) - by Makso - 09-10-2016, 01:02 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-10-2016, 04:03 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-10-2016, 06:20 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 05:43 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 06:40 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 07:00 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 07:07 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 07:28 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 07:33 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 07:46 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 08:09 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-26-2016, 03:11 PM
RE: Arduino - Remote control (RF-TX) - by Omegakg - 09-26-2016, 04:52 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-26-2016, 06:31 PM
RE: Arduino - Remote control (RF-TX) - by Omegakg - 09-26-2016, 06:57 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-26-2016, 07:14 PM
RE: Arduino - Remote control (RF-TX) - by Omegakg - 09-26-2016, 08:54 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-26-2016, 10:01 PM
RE: Arduino - Remote control (RF-TX) - by Omegakg - 09-27-2016, 10:38 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-27-2016, 12:40 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 09-27-2016, 03:40 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 09-27-2016, 04:37 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-27-2016, 05:32 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 09-27-2016, 07:58 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-27-2016, 08:07 PM
RE: Arduino - Remote control (RF-TX) - by npejcic - 09-27-2016, 09:09 PM
RE: Arduino - Remote control (RF-TX) - by Omegakg - 09-27-2016, 10:33 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-27-2016, 10:44 PM
RE: Arduino - Remote control (RF-TX) - by npejcic - 09-28-2016, 08:48 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-28-2016, 11:45 AM
RE: Arduino - Remote control (RF-TX) - by npejcic - 09-28-2016, 06:33 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-28-2016, 06:48 PM
RE: Arduino - Remote control (RF-TX) - by npejcic - 09-28-2016, 07:11 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-28-2016, 07:19 PM
RE: Arduino - Remote control (RF-TX) - by npejcic - 09-29-2016, 09:32 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 10-03-2016, 10:46 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 10-06-2016, 09:32 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 10-06-2016, 10:20 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 10-20-2016, 10:59 AM
RE: Arduino - Remote control (RF-TX) - by npejcic - 10-20-2016, 04:10 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 10-20-2016, 06:17 PM
RE: Arduino - Remote control (RF-TX) - by npejcic - 10-20-2016, 08:16 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-18-2017, 03:28 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 02-18-2017, 07:28 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-18-2017, 08:04 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 02-19-2017, 01:20 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 02-18-2017, 09:29 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-18-2017, 11:24 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 02-19-2017, 09:25 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-19-2017, 12:08 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-19-2017, 07:31 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-27-2017, 04:31 PM
RE: Arduino - Remote control (RF-TX) - by vsavic - 02-27-2017, 04:43 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 02-27-2017, 04:56 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 02-27-2017, 07:34 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-27-2017, 10:56 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 02-28-2017, 01:59 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-28-2017, 09:17 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 03-26-2017, 11:41 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-15-2017, 11:16 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 12-28-2017, 10:37 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 12-29-2017, 12:29 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 12-29-2017, 01:05 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-03-2018, 12:40 AM
RE: Arduino - Remote control (RF-TX) - by mikikg - 01-03-2018, 08:28 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-05-2018, 05:49 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-05-2018, 11:38 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-06-2018, 12:06 AM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-06-2018, 12:12 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-06-2018, 12:33 AM
RE: Arduino - Remote control (RF-TX) - by gorankg - 01-06-2018, 08:45 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-06-2018, 08:34 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-17-2018, 08:28 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-18-2018, 06:05 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-19-2018, 06:38 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-19-2018, 11:19 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-21-2018, 03:28 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-21-2018, 01:26 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-21-2018, 05:28 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-22-2018, 01:12 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-22-2018, 01:40 AM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-22-2018, 01:54 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-22-2018, 02:03 AM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-22-2018, 10:33 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-22-2018, 01:51 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-22-2018, 03:19 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-22-2018, 03:50 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 01-22-2018, 04:00 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-22-2018, 09:12 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-22-2018, 10:48 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-22-2018, 11:12 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-23-2018, 01:22 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-23-2018, 01:20 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-23-2018, 03:18 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-23-2018, 07:20 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 01-23-2018, 07:26 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-23-2018, 03:53 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-23-2018, 10:21 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-23-2018, 11:47 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-24-2018, 04:12 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-24-2018, 04:46 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-24-2018, 05:20 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-24-2018, 05:52 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 01-24-2018, 06:30 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-24-2018, 09:37 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-25-2018, 02:01 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-25-2018, 01:54 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-25-2018, 02:35 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-26-2018, 12:34 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-26-2018, 12:57 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-26-2018, 04:05 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-26-2018, 09:08 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-31-2018, 09:02 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-31-2018, 09:39 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-31-2018, 10:14 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-02-2018, 06:27 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 02-02-2018, 09:35 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-02-2018, 11:33 PM
RE: Arduino - Remote control (RF-TX) - by mikikg - 02-03-2018, 10:14 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-03-2018, 02:13 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-03-2018, 08:59 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 05-26-2018, 12:03 PM

Forum Jump:


Users browsing this thread: 6 Guest(s)