10 years, 2 months ago.

Joystick and LED ?

Question: Hi I just bought mbed 1768 with application board and play joystick as below file from cookbook.

Why joystick movement of up/down/left/right is mapped with LED1,2,3,4?

What it means "leds=joy" in below c program ?

Thanks -------------------------

  1. include "mbed.h"

BusIn joy(p15,p12,p13,p16); DigitalIn fire(p14);

BusOut leds(LED1,LED2,LED3,LED4);

int main() { while(1) { if (fire) { leds=0xf; } else { leds=joy; } wait(0.1); } }

--------------------

1 Answer

10 years, 2 months ago.

I don't know how it is mapped exactly, you could check the schematic, or just try it out ;).

leds = joy is equivalent to: leds.write(joy.read()); It writes to the BusOut object leds, what it reads from joy, one on one. So if p16 is high, it makes LED4 high.