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.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:c8531003d8f3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Sep 22 13:11:54 2014 +0000
@@ -0,0 +1,55 @@
+#include "mbed.h"
+
+Serial pc(USBTX, USBRX);
+
+//declare digitalIn pins (A0 - A4)
+DigitalIn enable0(PTB0);
+DigitalIn enable1(PTB1);
+DigitalIn enable2(PTB2);
+DigitalIn enable3(PTB3);
+DigitalIn enable4(PTC2);
+
+
+DigitalOut ledG(LED_GREEN);
+DigitalOut ledR(LED_RED);
+
+int main() {
+ //setup stuff
+ //enable all internal pullup resistors
+ enable0.mode(PullUp);
+ enable1.mode(PullUp);
+ enable2.mode(PullUp);
+ enable3.mode(PullUp);
+ enable4.mode(PullUp);
+
+
+ while(1) { //main loop
+ //poll all the switches ( I know this is inefficient but I'm too lazy to do interrupts and its 3 am...
+ if(!enable2) {
+ printf("rright\n");
+ }
+ else if(!enable3) {
+ printf("lleft\n");
+ }
+ else if(!enable0) {
+ printf("left\n");
+ ledR = 0;
+ ledG = 1;
+ }
+ else if(!enable1) {
+ printf("right\n");
+ ledR = 1;
+ ledG = 0;
+ }
+ else if(!enable4) {
+ printf("push\n");
+ }
+ else {
+ printf("notpush\n");
+ ledR = 0;
+ ledG = 0;
+ }
+
+
+ }
+}
\ No newline at end of file