Pinguino + Input Shield

Pin:

Pin Allocation:

Example: LED display using analog and digital button

Flow Chart:

Program Code:
#define x 15
#define y 14
#define button_A 5
#define button_B 3
#define button_C 4
#define LED_TOP 24
#define LED_BOTTOM 22
#define LED_RIGHT 25
#define LED_LEFT 23
#define LED_A 26
#define LED_B 27
#define LED_C 28
void setup()
{
int i;
for(i=3;i<=5;i++)
pinMode(i, INPUT);
for(i=22;i<=28;i++)
pinMode(i,OUTPUT);
}
void loop()
{
int valx,valy;
int i;
while(1)
{
digitalWrite(LED_LEFT, LOW);
digitalWrite(LED_RIGHT, LOW);
digitalWrite(LED_BOTTOM, LOW);
digitalWrite(LED_TOP, LOW);
digitalWrite(LED_A,LOW);
digitalWrite(LED_B,LOW);
digitalWrite(LED_C,LOW);
valx=analogRead(x); //Read Analog input
if(valx>1000)
digitalWrite(LED_LEFT, HIGH);
else if(valx<20)
digitalWrite(LED_RIGHT,HIGH);
valy=analogRead(y);
if(valy>1000)
digitalWrite(LED_BOTTOM, HIGH);
else if(valy<20)
digitalWrite(LED_TOP,HIGH);
if(digitalRead(button_A)==0)    //Check Button A
digitalWrite(LED_A, HIGH);   // Set LED on
else if(digitalRead(button_B)==0)   //Check Button B
digitalWrite(LED_B, HIGH);    // Set LED Off
else if(digitalRead(button_C)==0)   //Check Button C
digitalWrite(LED_C, HIGH);    // Set LED off
}
}

Demonstration:
[youtube]http://www.youtube.com/watch?v=gOj-vQolYfk[/youtube]

Buy

, ,

Related Post

Pinguino + XBee Shield

Pinguino + Graphic LCD Shield

Pinguino + 2 Amp Motor Driver Shield

PINGUINO

Leave a Reply

Your email address will not be published. Required fields are marked *