Use joystick to write position on to tera term using Interrupt

Dependencies:   mbed

main.cpp

Committer:
rudolf5020
Date:
2020-08-18
Revision:
0:685104e87cb2

File content as of revision 0:685104e87cb2:

#include "mbed.h" // 
 
Serial pc(USBTX,USBRX);     //serial communication to PC 
 
InterruptIn down(p12);      //declare Pin 12 joystick down
InterruptIn left(p13);      //declare Pin 13 joystick left
InterruptIn center(p14);    //declare Pin 14 joystick left
InterruptIn up(p15);        //declare Pin 15 joystick left
InterruptIn right(p16);     //declare Pin 16 joystick left
 
 
void Down(){
        pc.printf("DOWN\r\n");  //print on tera Term position in next line
    }

void Left(){
        pc.printf("LEFT\r\n"); 
        
    }     
void Center(){
        pc.printf("CENTER\r\n");    
    }

void Up(){
        pc.printf("UP\r\n"); 
}
void Right(){
    pc.printf("RIGHT\r\n");     
    }
    
int main(){
    while (1){
        down.rise(&Down); // switches on the rising edge
        left.rise(&Left); // switches on the rising edge
        center.rise(&Center); // switches on the rising edge
        up.rise(&Up); // switches on the rising edge
        right.rise(&Right); // switches on the rising edge
        down.rise(&Down); // switches on the rising edge
        }
}