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
main.cpp
00001 #include "mbed.h" 00002 00003 Serial pc(USBTX, USBRX); 00004 00005 //declare digitalIn pins (A0 - A4) 00006 DigitalIn enable0(PTB0); 00007 DigitalIn enable1(PTB1); 00008 DigitalIn enable2(PTB2); 00009 DigitalIn enable3(PTB3); 00010 DigitalIn enable4(PTC2); 00011 00012 00013 DigitalOut ledG(LED_GREEN); 00014 DigitalOut ledR(LED_RED); 00015 00016 int main() { 00017 //setup stuff 00018 //enable all internal pullup resistors 00019 enable0.mode(PullUp); 00020 enable1.mode(PullUp); 00021 enable2.mode(PullUp); 00022 enable3.mode(PullUp); 00023 enable4.mode(PullUp); 00024 00025 00026 while(1) { //main loop 00027 //poll all the switches ( I know this is inefficient but I'm too lazy to do interrupts and its 3 am... 00028 if(!enable2) { 00029 printf("rright\n"); 00030 } 00031 else if(!enable3) { 00032 printf("lleft\n"); 00033 } 00034 else if(!enable0) { 00035 printf("left\n"); 00036 ledR = 0; 00037 ledG = 1; 00038 } 00039 else if(!enable1) { 00040 printf("right\n"); 00041 ledR = 1; 00042 ledG = 0; 00043 } 00044 else if(!enable4) { 00045 printf("push\n"); 00046 } 00047 else { 00048 printf("notpush\n"); 00049 ledR = 0; 00050 ledG = 0; 00051 } 00052 00053 00054 } 00055 }
Generated on Tue Jul 12 2022 15:07:35 by
1.7.2