I want to implement the code using classes.The User is shown 3 options on LCD and buttons are assigned for the user input for example:
I want to implement the code using classes.The User is shown 3 options on LCD and buttons are assigned for the user input for example:
up: Joystick down: Potientometer Left: Temperature sensor Right: Terminate
and then if the user selects option one then the following code is executed but through classes:
Grove - Thumb Joystick mouse altered to work with MBED Application board //Constructor is blocking, so main will not run if the target's USB is not connected #include "mbed.h" #include "USBMouse.h"
USBMouse mouse; // x and y axis of the joystick //AnalogIn ainx(A0);
//Grove - Thumb Joystick mouse altered to work with MBED Application board //Constructor is blocking, so main will not run if the target's USB is not connected #include "mbed.h" #include "USBMouse.h"
USBMouse mouse; // x and y axis of the joystick //AnalogIn ainx(A0); //AnalogIn ainy(A1); BusIn*input = new BusIn(p15,p12,p13,p16); int16_t x; int16_t y;
int main() { while (1){int state = input->read(); // get current state from input x = 0; y = 0; switch(state & input->mask()) { //mask bits to test case 0x0: // do nothing - stick neutral position break; case 0x1: // stick down (relative to LCD screen) y = -1; break; case 0x2: // stick up y = 1; break; case 0x4: // stick left x = -1; break; case 0x8: // stick right x = 1; } // moves mouse to specified x, y coordinates on screen mouse.move(x, y); wait_us(500); } }
now the joystick on Mbed board should be working.Please note i need to implement this using classes
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started