Unknown Issue using Arduino, Xbees and Capacitive Sensor -


i'm having issue current set up.

i'm looking activate light on arduino 1 when capacitive sensor's (coiled wire) value goes above 100 on arduino 2. want activate light on arduino 2 when capacitive sensors value on arduino 1 exceeds 100. imagine if coil gameshow buzzer , led has light other contestants. i've used serial.println check how sensors operate.

the problem i'm getting when use code:

#include <newsoftserial.h>  #include <capacitivesensor.h>  newsoftserial myport(2,3); capacitivesensor   cs_6_4 = capacitivesensor(6,4);        // 10m resistor between pins 4 & 2, pin 2 sensor pin, add wire , or foil if desired int incomingbyte; void setup()                     {   cs_6_4.set_cs_autocal_millis(0xffffffff);     // turn off autocalibrate on channel 1 - example    serial.begin(9600);    myport.begin(9600);    pinmode(9,output); }  void loop()                     {   long start = millis();   long total1 =  cs_6_4.capacitivesensor(30); if (total1>100){    myport.print(1,byte);  } else{     myport.print(0,byte); } delay(10); if (myport.available()){ // set values ‘incomingbyte’ variable incomingbyte = myport.read(); serial.println(incomingbyte);  if (incomingbyte==1){ analogwrite(9, 255); }  else{ analogwrite(9, 0); } //else if (incomingbyte >=110 && incomingbyte <=70) { // write value pin 11 //val2 = map(incomingbyte, 110, 170, 0, 255); //analogwrite(9, int(val2)); } //serial.println(total1); } 

that code on both boards, , works extent. problem board works predictably small time after 1 of capacitive sensors activite (sometimes 4 seconds, 10) , lights flash on in short millisecond bursts. in serial monitor shows boards picking 1 value "incomingbyte" should happen when sensors exceeding 100.

there seems unreliable delay sensor touch light going on varies between immediate 1 second. isn't problem i'm hoping change result of incomingbyte function rather turn led on.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -