Arduino_Input_Shield_(SKU__DFR0008) - jimaobian/DFRobotWiki GitHub Wiki
Introduction
the arduino input shield includes a two axis mini joystick (with moment switch) as well as two colored push buttons. the reserved apc220 radio data module(sku:tel0005) interface is to facilitate the realization of wireless rocker button controller. the shield can be easily stacked on top of your Arduino.
Pin Allocation
Pin | Function |
---|---|
Digital 3 | Button B |
Digital 4 | Button C |
Digital 5 | Button A |
Analog 0 | Y axis |
Analog 1 | X axis |
Sample Code
//This input shield use Digital Pin 3,4,5 (3 buttons) and Analog Pin 0,1 (JS)
// // Upload the code to Arduino
// www.dfrobot.com
// Last modified on 24/12/2009
int x=1;
int y=0;
int button_A= 5;
int button_B= 3;
int button_C= 4;
void setup()
{
int i;
for(i=3;i<=5;i++)
pinMode(i, INPUT);
pinMode(LED,OUTPUT);
}
void loop()
{
int val;
while(1)
{
val=analogRead(x); //Read Analog input
if(val>1000||val<20) digitalWrite(LED, HIGH);
else digitalWrite(LED,LOW);
val=analogRead(y);
if(val>1000||val<20) digitalWrite(LED, HIGH);
else digitalWrite(LED,LOW);
if(digitalRead(button_A)==0) //Check Button A
{
digitalWrite(LED, HIGH); // Set LED on
}
else digitalWrite(LED,LOW);
if(digitalRead(button_B)==0) //Check Button B
{
digitalWrite(LED, HIGH); // Set LED Off
}
else digitalWrite(LED,LOW);
if(digitalRead(button_C)==0) //Check Button C
{
digitalWrite(LED, HIGH); // Set LED off
}
else digitalWrite(LED,LOW);
}
}
Documents
shopping arduino input shield (sku:dfr0008)
category: Product Manual category: DFR Series category: Shields category: source