Patrick Zieverink / Mbed 2 deprecated magnet_on_off

Dependencies:   mbed QEI HIDScope biquadFilter MODSERIAL FastPWM

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*
00002 To-do:
00003     Add reference generator
00004     fully implement schmitt trigger 
00005     Homing 
00006     Turning the magnet on/off
00007     Inverse kinematics
00008     Gravity compensation
00009     PID values
00010     General program layout
00011     better names for EMG input
00012 */
00013 
00014 #include "mbed.h"
00015 #include "MODSERIAL.h"
00016 #include "FastPWM.h"
00017 #include "QEI.h"
00018 #include "HIDScope.h"
00019 #include "BiQuad.h"
00020 #define PI 3.14159265
00021 
00022 Serial pc(USBTX, USBRX);            //connect to pc
00023 AnalogIn magnet(A5);
00024 
00025 Ticker magnet_tickerr;
00026 
00027 bool magnet_trigger;
00028 
00029 
00030 void magnet_ticker()
00031 {
00032     if (magnet > 0.2){
00033         magnet_trigger = true;
00034     }
00035     if (magnet < 0.2) {
00036         magnet_trigger = false;
00037     }
00038 }
00039 
00040 
00041 int main()
00042 {
00043     pc.baud(115200);
00044     pc.printf("Executing main()... \r\n");
00045 
00046     magnet_tickerr.attach(&magnet_ticker, 0.02);
00047     
00048         
00049     while (true) {
00050         wait(0.05f);
00051         
00052         if (magnet_trigger) {
00053             pc.printf("Magnet on \n\r");
00054         }
00055         else {
00056             pc.printf("Magnet off \n\r");
00057         }
00058 
00059     }
00060 }