Joystick

Dependencies:   mbed

Fork of app-board-Joystick by Chris Styles

Committer:
Planinsec
Date:
Wed Apr 29 15:31:31 2015 +0000
Revision:
1:6d189395a003
Parent:
main.cpp@0:0e4db18afd77
FTKL

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chris 0:0e4db18afd77 1 #include "mbed.h"
chris 0:0e4db18afd77 2
Planinsec 1:6d189395a003 3 BusIn biJoy(p15,p12,p13,p16);
Planinsec 1:6d189395a003 4 DigitalIn diFire(p14);
chris 0:0e4db18afd77 5
Planinsec 1:6d189395a003 6 BusOut doLeds(LED1,LED2,LED3,LED4);
chris 0:0e4db18afd77 7
chris 0:0e4db18afd77 8 int main()
chris 0:0e4db18afd77 9 {
Planinsec 1:6d189395a003 10 doLeds=0;
Planinsec 1:6d189395a003 11
chris 0:0e4db18afd77 12 while(1) {
Planinsec 1:6d189395a003 13 if (diFire)
Planinsec 1:6d189395a003 14 {
Planinsec 1:6d189395a003 15 doLeds=0;
Planinsec 1:6d189395a003 16 }
Planinsec 1:6d189395a003 17
Planinsec 1:6d189395a003 18 if (biJoy==1)
Planinsec 1:6d189395a003 19 {
Planinsec 1:6d189395a003 20 doLeds=doLeds<<1;
Planinsec 1:6d189395a003 21
Planinsec 1:6d189395a003 22 if (doLeds==16 ||doLeds== 0)
Planinsec 1:6d189395a003 23 {
Planinsec 1:6d189395a003 24 doLeds=1;
Planinsec 1:6d189395a003 25 }
chris 0:0e4db18afd77 26 }
Planinsec 1:6d189395a003 27
Planinsec 1:6d189395a003 28 if (biJoy==2)
Planinsec 1:6d189395a003 29 {
Planinsec 1:6d189395a003 30 doLeds=doLeds>>1;
Planinsec 1:6d189395a003 31
Planinsec 1:6d189395a003 32
Planinsec 1:6d189395a003 33 if (doLeds==16||doLeds==0)
Planinsec 1:6d189395a003 34 {
Planinsec 1:6d189395a003 35 doLeds=8;
Planinsec 1:6d189395a003 36 }
Planinsec 1:6d189395a003 37 }
Planinsec 1:6d189395a003 38
Planinsec 1:6d189395a003 39 wait(0.5);
chris 0:0e4db18afd77 40 }
chris 0:0e4db18afd77 41 }