Arduino_Input_Shield__SKU__DFR0008_-DFRobot

Introduction

Arduino Input Shield

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);
  }
}

More Documents

DFshopping_car1.png Get Arduino Input Shield from DFRobot Store or DFRobot Distributor.

Category: DFRobot > Arduino > Arduino Shields

category: Product Manual category: DFR Series category: Shields category: source

Turn to the Top