Sumit Pandey / Mbed 2 deprecated joystickserial

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 AnalogIn inputj1(p17);     //inputs 17,18,19,20  for interfacing with 4 potentiometers in 2 joysticks. 
00004 AnalogIn inputj2(p18);
00005 AnalogIn inputk1(p19);
00006 AnalogIn inputk2(p20);
00007 
00008 Serial pc(USBTX,USBRX);  // Serial class to interface with serial data
00009 int x =50,y=50,z=50,w=50;
00010  
00011 int main() 
00012 {
00013 pc.baud(9600); // fixing the baud rate of transmission to 9600 bps.
00014 while(1)
00015         {  
00016         x=inputj1*100;
00017         y=inputj2*100;
00018         z=inputk1*100;
00019         w=inputk2*100; 
00020         pc.printf("%d,%d,%d,%d*",x,y,z,w);   //transmittion the joystick data to computer.
00021         //wait(0.05);
00022         }   
00023 }