/* 03.02.2019 Written by: Gabby Shimoni Description: This program makes and RGB led shine based on input from joystick as follows: X value control the RED led Y axis controls the GREEN led pb turns the BLUE led ON */ #define redLedPin 9 #define greenLedPin 11 #define blueLedPin 10 #define pbPin 2 int pbState = 0; #define potXpin A0 #define potYpin A1 int potXval = 0, potYval = 0; void setup() { Serial.begin(9600); pinMode(redLedPin, OUTPUT); pinMode(greenLedPin, OUTPUT); pinMode(blueLedPin, OUTPUT); pinMode(pbPin, INPUT); } void loop() { potXval = analogRead(potXpin); potYval = analogRead(potYpin); pbState = digitalRead(pbPin); potXval = map(potXval, 0, 1023, 0, 255); potYval = map(potYval, 0, 1023, 0, 255); analogWrite(redLedPin, potXval); analogWrite(greenLedPin, potYval); if (pbState==HIGH) { digitalWrite(blueLedPin, HIGH); } else { digitalWrite(blueLedPin, LOW); } delay(200); }