updated codes lads
Dependencies: C12832 Servo mbed-rtos mbed
Fork of rtos_basic_team by
main.cpp
- Committer:
- Ali_taher
- Date:
- 2015-01-28
- Revision:
- 9:f60eeadabcb0
- Parent:
- 8:507111cc659c
- Child:
- 10:372c5d608b5c
File content as of revision 9:f60eeadabcb0:
#include "mbed.h" #include "rtos.h" #include "Servo.h" #include "C12832.h" Servo s1(p21); Servo s2(p22); AnalogIn p1(p17); //AnalogIn p2(p20); Mutex dataIn_mutex; Mutex dataOut_mutex; // Globel variables float input_data; float output_data; C12832 lcd(p5, p7, p6, p8, p11);// lcd is an object from class c12832 initialised by p5,p7.... void sonar_thread(void const *args) { while (true) { dataIn_mutex.lock(); input_data= p1.read()*5; lcd.cls(); // clear the display lcd.locate(0,3);// the location where you want your charater to be displayed lcd.printf("Thread one = %f\n", input_data); dataIn_mutex.unlock(); Thread::wait(25); } } void control_thread(void const *args) { while (true) { dataIn_mutex.lock(); if (input_data>0.8) { s2=input_data*0.2; } else if(input_data<0.8) { s2=-input_data*0.5; } s1=input_data; dataIn_mutex.unlock(); Thread::wait(20); } } int main() { Thread thread(sonar_thread); Thread thread_1(control_thread); while (true) { Thread::wait(10); } }