Open arduino IDE then copy and paste this code.
The code is based totally on 10 easy analogWrite instructions.
i am now not a good programmer at all, i'm still in 11th grade and should deal with my academics/college so I cant spend an awful lot time gaining knowledge of coding, there may be lot of errors inside the application and i will surprisingly appreciate the tips for development. The code just beneath is the correct working, do no longer use the older one.
#include <OneSheeld.h>
int ledPin1 = 11;
float xOrientation;
void setup() {
/* Start communication. */
OneSheeld.begin();
pinMode(ledPin1,OUTPUT);
}
void loop() {
// Check X-axis orientation.
xOrientation = OrientationSensor.getX();
// Map orientation to brightness
if(xOrientation < 102) analogWrite(ledPin1,xOrientation * 2.5);
// Or turn off the LED if the orientation is > 125 degrees
else analogWrite(ledPin1, 0);
}