Hello.
I'm just starting to build a simple arduino program to make motors and lights move in sequence.
I don't have enough pins on my arduino Duemilanove to control all the motors plus to turn the LED's on/off individually in the way that I want.
Therefore I'm thinking to organise the LEDs on a separate arduino board, controlling this 2nd board from the main board to start the light loops.
I would like to have a number of different light routines programmed on the 2nd board, and to trigger them at different times using different commands. The problem is, I have no idea how to start them talking.
This is how I would set up the code on the main board, Arduino 1. I'm really not sure what command to use to send a signal from 1 to 2 though, so it is rather bare :
#define TOARDUINO2 3 //arduino2 connected to digital pin 3
void setup()
{
pinMode(TOARDUINO2, OUTPUT) //sets the digital pin as output
}
void loop()
{
digitalWrite???(TOARDUINO2,???) //I want to send different signals, ie '1', '2' and '3' to Arduino board 2
}
And below would be the code for the 2nd board, for the lights:
#define FROMARDUINO1 13 //arduino1 connected to digital pin 13
int state = 0; // to read the value coming from Arduino 1
void setup()
{
pinMode(FROMARDUINO1, INPUT); //sets the digital pin as input
}
void loop()
{
state = digitalRead(FROMARDUINO1);
switch(state)//
{case '1'://
//code to run light rountine 1
}
{case '2':
//code to run light routine 2
}
{case '3':
//code to run light routine 3
}
}
I'm using the 'state' command because I used it in a previous programme, to talk to the serial monitor, using:
if (Serial.available() > 0) { //if there is input from the serial monitor
{
state = Serial.read(); // used to read incoming data
and it feels like it is close to what I need.
Any advice gratefully received. Thanks.