Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "DemoBoard.h" 00002 00003 /* 00004 * This project uses the LCD, the two pots, and the three buttons to make a simple 00005 * Etch-a-Sketch. Set the colour using the buttons, and use the pots to draw! 00006 * Oh yeah, more than 1.5 in any axis will clear the screen :-) 00007 */ 00008 00009 int colour = 0x0; 00010 00011 // Functions to set the draw colour. Write this to the RGB LED 00012 void RedRise() { colour = 0xff0000; rgb.write(colour);} 00013 void GreenRise() { colour = 0x00ff00; rgb.write(colour);} 00014 void BlueRise() { colour = 0x0000ff; rgb.write(colour);} 00015 00016 int main() { 00017 00018 00019 // Attach the colour set functions to 00020 // rising edge interrupt handlers 00021 RedButton.rise(&RedRise); 00022 GreenButton.rise(&GreenRise); 00023 BlueButton.rise(&BlueRise); 00024 00025 // set the screen background to white 00026 lcd.fill(0,0,130,130,0xffffff); 00027 00028 while(1) { 00029 // fetch the values from the pots, and scale them to 0-130 00030 int x = potx * 130; 00031 int y = poty * 130; 00032 00033 // draw the pixel! 00034 lcd.pixel(x,y,colour); 00035 wait(0.01); 00036 00037 // If any axis of the accelerometer read > 1.5g, clear the screen 00038 if ( (acc.x() > 1.5) || (acc.y() > 1.5) || (acc.x() > 1.5) ) { 00039 lcd.cls(); 00040 lcd.fill(0,0,130,130,0xffffff); 00041 } 00042 00043 } 00044 00045 } 00046 00047
Generated on Sun Jul 17 2022 14:53:20 by
1.7.2