Reproduces problem with having different analogIn in both ticker and main

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 DigitalIn Button1(p21);    
00004 DigitalOut led1(LED1);
00005 
00006 AnalogIn Joystick1(p18);    
00007 AnalogIn Ain3(p15);
00008 
00009 float LFT;                 
00010 int LowBatteryCounter=0;
00011 
00012 Ticker VoltageCheck_tick;               
00013 
00014 void LowBatteryShutDown(void); 
00015        
00016 
00017 int main() 
00018 {
00019     VoltageCheck_tick.attach(&LowBatteryShutDown,0.5);  
00020       
00021     while(1) 
00022     {
00023        if (Button1==1)
00024        {
00025              LFT = Joystick1;
00026        } 
00027     }
00028 }
00029 
00030 void LowBatteryShutDown(void)  
00031 {
00032     led1 = !led1;
00033     
00034     if(Ain3<=0.81)
00035     {
00036         LowBatteryCounter++;
00037     }
00038 }
00039