The Start


Hi, What and Why

Plug it in

Rule number 1

Water Sensor

Sound Sensor

Joystick

Tri Colour LED

RTC (Real Time Clock) DS1302

RTC (Real Time Clock) DS3231

Matrix LED step 1

LCD

Stepper Motor

LCD revisited with PCF8574T

Humidity Sensor

Shift Register

RFID tags (RC-522)

7 Segment display

Ultrasonic distance sensor

5V regulator

analogRead and analogWrite

Wiring an Array of Switches

The next step


Other things I have bought

Infra red and Processing

Programming a separate arduino chip

Creating your own PCB

L293D for a DC motor

4 digit 7 segment display

Starting with motors

RF433 Wireless Comms

Sort a character array

More stuff


I2C devices (SDA,SCL)

I2C scanner

SPI devices (MOSI,MISO)

HMC5883L Compass

MMA7361 Accelerometer

Added projects


Message Display System

4WD robot car
4WD robot car II

4WD robot car COMPLETE

MP3 Player

Joystick


The Joystick. joystick

There are 5 pins. GND, +5V, VRx, VRy and SW. I would guess that SW is digital (1 or 0 for the switch, activated by clicking the joystick down), and VRx and VRy are analog, returning values depending on how the joystick is moved sideways. So I wired it accordingly.

Wired up.

Arduino 5V -> breadboard -> resistor -> LED -> Joystick +

Joysticks GND - -> breadboard -> Arduino GND

The yellow pin from the water sensor is now ready to read.
joystick

This is the code that I used.

   /*
Read the Joystick. Try reading the analog values, and / or the digital value, to see what returns.
*/
int analogInputPinX   = 3;
int analogInputPinY   = 5;
int digitalInputPin  = 2;
int wait = 1000; 
long analogInputValX;
long analogInputValY;
int digitalInputVal;

void setup()
{
  pinMode(analogInputPinX,   INPUT);
  pinMode(analogInputPinY,   INPUT);
  pinMode(digitalInputPin,   INPUT);
  
  Serial.begin(9600);  // ...set up the serial ouput on 0004 style
}

void loop()
{
  analogInputValX = analogRead(analogInputPinX);
  analogInputValY = analogRead(analogInputPinY);
  digitalInputVal = digitalRead(digitalInputPin);
  
      Serial.print("Digital is ");
      Serial.print(digitalInputVal);
      Serial.print(" and Analog X is ");
      Serial.print(analogInputValX);    
      Serial.print(" and Analog Y is ");
      Serial.print(analogInputValY);    
      Serial.println(" "); // println, to end with a carriage return
   
  delay(wait); // Pause for 'wait' milliseconds before resuming the loop
}
That code led to these results :
joystick
So I changed the code to remove the loop, and only print values when they changed. Here is the code :

/*
Read the joystick. Only print values that change.
*/
int analogInputPinX   = 3;
int analogInputPinY   = 5;
int digitalInputPin  = 2;
int wait = 1000; 
long analogInputValX;
long analogInputValY;
long last_analogInputValX;
long last_analogInputValY;
int digitalInputVal;

void setup()
{
  pinMode(analogInputPinX,   INPUT);
  pinMode(analogInputPinY,   INPUT);
  pinMode(digitalInputPin,   INPUT);
  
  Serial.begin(9600);  // ...set up the serial ouput on 0004 style
}

void loop()
{
  analogInputValX = analogRead(analogInputPinX);
  analogInputValY = analogRead(analogInputPinY);
  digitalInputVal = digitalRead(digitalInputPin);
  if (digitalInputVal != 0)
      {
      Serial.print("YAY ! Digital is ");
      Serial.print(digitalInputVal);
      Serial.println(" "); // println, to end with a carriage return
      }        
  if (analogInputValX != last_analogInputValX)
      {
      Serial.print("Change X to ");
      Serial.print(analogInputValX);    
      Serial.println(" "); // println, to end with a carriage return
      last_analogInputValX = analogInputValX;
      }
  if (analogInputValY != last_analogInputValY)
      {
      Serial.print("Change Y to ");
      Serial.print(analogInputValY);    
      Serial.println(" "); // println, to end with a carriage return
      last_analogInputValY = analogInputValY;
      }

}
   
And here is the resulting screenshot :
That code led to these results :
joystick