Pong game for ELEC1620 board.

Embed: (wiki syntax)

« Back to documentation index

Joystick Class Reference

Joystick Class Reference

Joystick Class. More...

#include <Joystick.h>


Detailed Description

Joystick Class.

Author:
Dr Craig A. Evans, University of Leeds Library for interfacing with analogue joystick

Example:

#include "mbed.h"
#include "Joystick.h"

//                  y     x     button
Joystick joystick(PTB11,PTB10);

int main() {
    
    joystick.init();
    
    while(1) {
    
        Vector2D coord = joystick.get_coord();
        printf("Coord = %f,%f\n",coord.x,coord.y);
        
        Vector2D mapped_coord = joystick.get_mapped_coord(); 
        printf("Mapped coord = %f,%f\n",mapped_coord.x,mapped_coord.y); 
        
        float mag = joystick.get_mag();
        float angle = joystick.get_angle();
        printf("Mag = %f Angle = %f\n",mag,angle);
        
        Direction d = joystick.get_direction();
        printf("Direction = %i\n",d);
    
          
        wait(0.5);
    }
    
    
}

Definition at line 55 of file Joystick.h.