So Im working on a project (Wooohoo)
To implement a pace clock system that is wireless using 4 Xbee's and 4 Arduinos
CORD -> 3X ROUT and each ROUT -> CORD at least in theory this is how I would like to setup this
There are 2 elements that matter is the Time from the router from when the last time that button was pushed
and then there is the level of WIP = This is just a number that decreases with each button push is hit but in creases with the router to the right of them has been pushed also
AKA R"X" (WIP) -> R1(3) R2(3) R3(3) now say R1 pushes there button it would look like this -> R1(2) R2(4) R3(3) given that R2 hasnt pushed there button
So I'm not sure if im losing it but it seems like the world really starts to look grey when I introduce API mode...
Here is an example of the code if all I cared about was a single serial output onto a serial LCD screen I have....
const int TxPin = 6;
#include <SoftwareSerial.h>
SoftwareSerial mySerial = SoftwareSerial(255, TxPin);
int button = 7; //button attached to pin 7
int val; // reads the button state in loop
int val2; // reads the button state a second time
int state; // reads the button state in setup and stores it could have called this button old
int press = 1; // press counter, i set this to 1 so when the first button is pressed it will give a value of 0 activating the first pin
unsigned long time;
unsigned long time2;
unsigned long time3;
unsigned long time4;
int RedO = 13;
int YelO = 12;
int GrnO = 11;
int button1hit = 0; // secondary code switch stops code running before a button has been pressed
void setup() {
pinMode(button, INPUT);
pinMode(TxPin, OUTPUT);
pinMode(RedO, OUTPUT);
pinMode(YelO, OUTPUT);
pinMode(GrnO, OUTPUT);
state = digitalRead(button); // read button state and store it to reference against later
digitalWrite(TxPin, HIGH);
digitalWrite(GrnO, HIGH);
mySerial.begin(9600);
delay(100);
mySerial.write(12); // Clear
mySerial.write(17); // Turn backlight on
delay(5); // Required delay
mySerial.print("UNT EE"); // First line
mySerial.write(13); // Form feed
mySerial.print("Project 6"); // Second line
delay(3000); // Wait 3 seconds
}
void loop()
{
time = millis();
time2 = ((millis()-time3)/1000) % 60; THIS IS JUST ME GETTING FANCY AND ISNT NEEDED ITS JUST MAKING THE TIME LOOK LIKE A CLOCK
time4 = (((millis()-time3)/1000) / 60) % 60;
val = digitalRead(button);
delay(10); // wait 10 millis to counter debounce
val2 = digitalRead(button); //check again to see if button is pressed
if (time2 == 10){
digitalWrite(RedO,HIGH);
digitalWrite(YelO,LOW);}
if (time2 == 6){
digitalWrite(YelO,HIGH);
digitalWrite(GrnO,LOW);}
if ((val == val2) && (val != state) && (val == HIGH))
{
press++; // counts button presses
if (press > 1)
{
press = 0; //when button press count passes 1 it resets to zero
}
if (press == 0 or press == 1)
{
mySerial.write(12); // Clear
delay(5); // Required delay
mySerial.print("Time="); // First line
mySerial.print(time4);
mySerial.print(":");
mySerial.print(time2);
mySerial.write(13); // Form feed
mySerial.print("TIMETAKEN"); // Second line
mySerial.write(212); // Quarter note
time3=time ;
digitalWrite(RedO,LOW);
digitalWrite(YelO,LOW);
digitalWrite(GrnO,HIGH);
}
}
state = val;
}
The 3 LEDS just pace the "USER" into hurrying giving them a visual indicator...
I have a few questions for the arduino world
Can I just use AT Mode? I can accept dropping the WIP feature if it means I can make more progress quicker.....
Last is there an easy way in API mode to send strings or "Longs" across api mode and how can they be read?
Thank you for your help to the new man!