const int LRpin = A0;
const int UDpin = A1;
// variables for analog readings
int LR;
int UD;
// neutral readings for calibration
int LR_neutral;
int UD_neutral;
// red, yellow, green, blue LED pins
const int Rpin = 11;
const int Ypin = 10;
const int Gpin = 6;
const int Bpin = 9;
// LED brightnesses
int R;
int Y;
int G;
int B;
const int deadzone=10;
void setup() {
// put your setup code here, to run once:
// Initialize serial communication
Serial.begin(9600);
// get neutral readings for calibration
// make sure you are not touching the joystick when
// the program starts!
LR_neutral = analogRead(LRpin);
UD_neutral = analogRead(UDpin);
}
void loop() {
// put your main code here, to run repeatedly:
// read analog pins
LR = analogRead(LRpin);
UD = analogRead(UDpin);
R=LR/4;
Serial.print("LR ");
Serial.print (LR);
Serial.print("\t");
Serial.print (R);
Serial.print("\t UD ");
Serial.println(UD);
analogWrite(Rpin,R);
delay(1000);
}