#define CUSTOM_SETTINGS
#define INCLUDE_ACCELEROMETER_SENSOR_SHIELD
#include <OneSheeld.h>
int pin5 = 5;
int pin6 = 6;
int pin9 = 9;
int pin10 = 10;
int pin3=3;
int pin11=11;
void setup()
{
/* Start communication. */
OneSheeld.begin();
/* Set the LED pin as output. */
pinMode(pin5,OUTPUT);
pinMode(pin6,OUTPUT);
pinMode(pin9,OUTPUT);
pinMode(pin10,OUTPUT);
pinMode(pin3,OUTPUT);
pinMode(pin11,OUTPUT);
}
void loop()
{
if(AccelerometerSensor.getY() > 5 )
{
analogWrite(pin5,200);
analogWrite(pin6,0);
analogWrite(pin9,255);
analogWrite(pin10,0);
analogWrite(pin3,255);
analogWrite(pin11,0);
}
if(AccelerometerSensor.getY() < -5 )
{
analogWrite(pin5,0);
analogWrite(pin6,200);
analogWrite(pin9,0);
analogWrite(pin10,255);
analogWrite(pin3,0);
analogWrite(pin11,255);
}
if(AccelerometerSensor.getX() > 5)
{
analogWrite(pin5,0);
analogWrite(pin6,0);
analogWrite(pin9,255);
analogWrite(pin10,0);
}
if(AccelerometerSensor.getX() < -5)
{
analogWrite(pin5,200);
analogWrite(pin6,0);
analogWrite(pin9,0);
analogWrite(pin10,0);
}
if(AccelerometerSensor.getZ() > 9)
{
analogWrite(pin5,0);
analogWrite(pin6,0);
analogWrite(pin9,0);
analogWrite(pin10,0);
analogWrite(pin3,0);
analogWrite(pin11,0);
}
}
Comments