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:
- 4:535e67099871
- Parent:
- 3:d3a088bc04e7
- Child:
- 5:6f51a96a5094
--- a/main.cpp Fri Jan 22 20:03:03 2016 +0000
+++ b/main.cpp Fri Jan 22 20:20:20 2016 +0000
@@ -5,14 +5,16 @@
//DECLARATIONS
Serial pc(USBTX, USBRX);
//Digital Inputs
-DigitalIn testIn(p25);
+DigitalIn testIn(p24);
//Digital Outputs
-DigitalOut testOut(LED1);
+DigitalOut testOut(p25);
//Analog Inputs
AnalogIn AIn(p26);
//Analog Outputs
AnalogOut AOut(p27);
AnalogOut BOut(p28);
+//PWM Outs
+PWMOut pulse(p21);
char DisplayMenu(void){
@@ -72,6 +74,16 @@
int fPWMOut(){ //generate a PWM output using one of the six PWM channels on the MBED.
//Assume the value of the period and the on-time is read from the keyboard
+//Specify Period First
+int Key
+printf("\n\r\n\r-----Robotics PWM Options-----\n\n\r");
+printf("Type the period in seconds:");
+printf("\n\rKeypress = ");
+Key = pc.getc();
+pulse.period(Key);
+printf("\n\r Enter the pulse width in seconds.");
+Key = pc.getc();
+pulse.pulsewidth(Key);
}
int ExternalIntInit(){//initialize an external interrupt that causes an LED to toggle its state each
@@ -137,8 +149,8 @@
Key=DisplayMenu();
if(Key=='1') SimpleIO(); //LAB 2.2
else if(Key=='2') fAnalogOut(); //LAB 2.3
- else if(Key=='3') fAnalogIn(); //LAB 2.4
- else if(Key=='4') fPWMOut(); //LAB 2.5
+ else if(Key=='3') fAnalogIn(); //LAB 2.4
+ else if(Key=='4') fPWMOut(); //LAB 2.5
else if(Key=='5') TimerIntInit(); //LAB 2.6
else if(Key=='6') ExternalIntInit(); //LAB 2.7
else if(Key=='7') LinearOpticalArrayTest(); //LAB 2.8