Biorobotics_group_2 / Mbed 2 deprecated Read_potentiometer

Dependencies:   HIDScope mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "HIDScope.h"
00003  
00004 // Define the HIDScope and Ticker object
00005 HIDScope    scope(1);
00006 Ticker      scopeTimer;
00007  
00008 // Read the analog input
00009 AnalogIn    a0(A0);
00010 
00011 // Set LED out
00012 DigitalOut  led(LED_RED);
00013  
00014 const float kTimeLedToggle = .5f;  // period of blinking
00015 const int   kLedOn=0;             // Led on if 0
00016  
00017 // The data read and send function
00018 void scopeSend()
00019 {
00020     scope.set(0, a0.read());
00021     scope.send();
00022 }
00023 
00024 void SwitchLed(){
00025     led = not led;
00026 }
00027  
00028 int main()
00029 {
00030     led = not kLedOn;
00031     
00032     // Create ticker for LED and attach
00033     Ticker tick_toggle_led;
00034     tick_toggle_led.attach(SwitchLed,kTimeLedToggle);
00035     
00036     // Attach the data read and send function at 100 Hz
00037     scopeTimer.attach(scopeSend, 1e4);
00038    
00039     while(true);
00040 }