/** 4d systems OLED video screen + accelerometer code by RenderMan see www.renderlab.net/projects/goggles-v2 for build details This code is rough and was only to test using an accelerometer to change images on the OLED screens Many nights and beers were spent at ENTS.ca, the Edmonton hackerspace hanging out tinkering. At the moment it takes input from an accelerometer to change images based on tilt direction I'm just learning, it's mangled and copy and pasted from a bunch of different sources, mostly the default ardiono examples It's ugly but it works. Feel free to use, fold spindle and mutilate. This code is creative commons if anyone cares **/ #include #include uOLED uoled; // Instance of OLED object int buttonState = 0; const int groundpin = 18; // analog input pin 4 -- ground const int powerpin = 19; // analog input pin 5 -- voltage const int xpin = A3; // x-axis of the accelerometer //const int ypin = A2; // y-axis //const int zpin = A1; // z-axis (only on 3-axis models) //const int led1 = 13; //const int led2 = 12; void setup() { delay (1000); uoled.begin(10,115200, &Serial); //reset line connected to pin 10 and a serial speed of 115200, hardware serial port (the only one on an Uno or Duemilanove) uoled.DeviceInfo(); // display some hardware/software info of the screen delay(5000); // info will be on screen for 2 seconds uoled.Cls(); // clears the screen of everything on it. It uses the background color (at this moment it's at default black) pinMode(groundpin, OUTPUT); pinMode(powerpin, OUTPUT); digitalWrite(groundpin, LOW); digitalWrite(powerpin, HIGH); //digitalWrite(led1, LOW); //digitalWrite(led2, LOW); } void loop(){ // uoled.sdDisplayImage(0, 0, 96, 64, 16, 0x001000); if (analogRead(xpin) < 450) { uoled.sdDisplayImage(0, 0, 96, 64, 16, 0x001000); } else { if (analogRead(xpin) > 550) { uoled.sdDisplayImage(0, 0, 96, 64, 16, 0x001017); } else { if (analogRead(xpin) > 450 && (analogRead(xpin) < 550)) { uoled.sdDisplayImage(0, 0, 96, 64, 16, 0x00102F); } } } }