hello guys I have search for 3 days and tried lots of different methods but nothing has worked as of yet.
so I have two arduinos and two xbees, I need to trigger a 4 pins on Arduino 2 (BB-8) with 4 push buttons on Arduino 1 (remote). seems easy huh ??? for some reason not for me. this is my remote code and BB-8 dome code, any help is much appreciated. also I have changed my setting on my Xbee multiple times to many different configurations trying to make them communicate while on Arduino but nothing. I'm thinking its a power issue??
//this is for the remote//
int potPin1 = 1;
int potPin2 = 2;
int potPin3 = 3;
int potPin4 = 4;
int potPin5 = 5;
int button1 = 3;
int button2 = 4;
int button3 = 5;
int button4 = 6;
int val6 = 0;
int val7 = 0;
int val8 = 0;
int val9 = 0;
int analogValue1;
int analogValue2;
int analogValue3;
int analogValue4;
int analogValue5;
int audio;
void setup()
{
//Create Serial Object (9600 Baud)
Serial.begin(9600);
pinMode(button1, INPUT);
pinMode(button2, INPUT);
pinMode(button3, INPUT);
pinMode(button4, INPUT);
}
void loop()
{
int val1 = map(analogRead(0), 0, 1023, 0, 180);
int val2 = map(analogRead(1), 0, 1023, 0, 180);
int val3 = map(analogRead(2), 0, 1023, 0, 180);
int val4 = map(analogRead(3), 0, 1023, 0, 50);
int val5 = map(analogRead(4), 0, 1023, 0, 180);
val6 = digitalRead(button1);
val7 = digitalRead(button2);
val8 = digitalRead(button3);
val9 = digitalRead(button4);
if (val6 == HIGH) {
Serial.println("A");
}
if (val7 == HIGH) {
Serial.println("B");
}
if (val8 == HIGH) {
Serial.println("C");
}
if (val9 == HIGH) {
Serial.println("D");
}
if (val6 == LOW) {
Serial.println("E");
}
if (val7 == LOW) {
Serial.println("F");
}
if (val8 == LOW) {
Serial.println("G");
}
if (val9 == LOW) {
Serial.println("H");
}
Serial.write(',');
Serial.write(val1);
Serial.write(val2);
Serial.write(val3);
Serial.write(val4);
Serial.write(val5);
Serial.write(val6);
Serial.write(val7);
Serial.write(val8);
Serial.write(val9);
delay(25);
}
// I didn't put all the lighting code I just need to get this part fixed and working, this is the dome//
void setup()
{
Serial.begin(9600); //setup serial connection
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(13, OUTPUT);
//initialize all our LED sections
Radar.begin();
Holo.begin();
PSI.begin();
Side.begin();
// Kick off a pattern
Radar.SolidColorRadar(Radar.Color(255,0,0));
Holo.RainbowCycle(25);
Side.Fade(Side.Color(0,0,100), Side.Color(0,0,05), 100, 40, REVERSE);
PSI.SoundPulse();
}
// Main loop
void loop() {
if(Serial.available()> 0 ) // if data is available to read
{;}
int val = Serial.read(); // read it and store it in 'val'
{
//this switch is for creating various patterns based on the character received from the bluetooth module (or serial terminal from arduino software)
switch (val) {
case 'A':
Radar.Scanner(Radar.Color(100,0,0), 100); // Radar scans Cylon style red with 100ms interval
Holo.RainbowCycle(25); //1ms fast rainbow cycle
//PSI.SolidColorRadar(PSI.Color(0,0,100)); // set the PSU to solid blue
Side.Random(200, 0,1,1); //Sides randomly blink at 200ms intervals red off, green on, blue on
digitalWrite(9, HIGH);
break;
case 'B':
// PSI.Fade(PSI.Color(0,0,100), PSI.Color(0,100,0), 500, 1, FORWARD); //fase from green to blue
Holo.SolidColorRadar(Holo.Color(0,0,100)); //Holo solid blue
digitalWrite(10, HIGH);
break;
case 'C':
Radar.Scanner(Radar.Color(0,100,0), 100); //scan green
Holo.RainbowCycle(25); //rainbow 25ms
Side.TheaterChase(Side.Color(0,0,100), Side.Color(0,100,0), 50, FORWARD); //lights chase green and blue 50ms
digitalWrite(11, HIGH);
break;
case 'D':
Radar.Scanner(Radar.Color(0,100,00), 100);
Holo.RainbowCycle(1);
//PSI.Fade(Radar.Color(0,0,255), Radar.Color(0,0,05), 25, 100, REVERSE);
Side.Fade(Side.Color(0,0,100), Side.Color(0,0,05), 100, 40, REVERSE);
digitalWrite(13, HIGH);
break;
case 'E':
digitalWrite(9, LOW);
break;
case 'F':
digitalWrite(10, LOW);
break;
case 'G':
digitalWrite(11, LOW);
break;
case 'H':
digitalWrite(13, LOW);
break;
} }
}