fancy lampje

Dependencies:   mbed QEI HIDScope biquadFilter MODSERIAL FXOS8700Q FastPWM

Committer:
MatthewMaat
Date:
Wed Sep 11 09:38:22 2019 +0000
Revision:
3:46c11151e0fd
Parent:
2:626688c21b6f
Child:
4:f988679bf9a1
Kies kleur, met ticker

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RobertoO 0:67c50348f842 1 #include "mbed.h"
RobertoO 0:67c50348f842 2 //#include "HIDScope.h"
RobertoO 0:67c50348f842 3 //#include "QEI.h"
RobertoO 1:b862262a9d14 4 #include "MODSERIAL.h"
RobertoO 0:67c50348f842 5 //#include "BiQuad.h"
RobertoO 1:b862262a9d14 6 //#include "FastPWM.h"
MatthewMaat 2:626688c21b6f 7 #include <iostream>
RobertoO 0:67c50348f842 8
MatthewMaat 2:626688c21b6f 9 DigitalOut ledred(LED_RED);
MatthewMaat 2:626688c21b6f 10 DigitalOut ledblue(LED_BLUE);
MatthewMaat 2:626688c21b6f 11 DigitalOut ledgreen(LED_GREEN);
RobertoO 0:67c50348f842 12
RobertoO 1:b862262a9d14 13 MODSERIAL pc(USBTX, USBRX);
MatthewMaat 3:46c11151e0fd 14 Ticker Theticker;
MatthewMaat 3:46c11151e0fd 15 volatile char c='x';
MatthewMaat 3:46c11151e0fd 16 void Take_Measurement(void)
MatthewMaat 3:46c11151e0fd 17 {
MatthewMaat 3:46c11151e0fd 18 if (c=='r')
MatthewMaat 3:46c11151e0fd 19 {
MatthewMaat 3:46c11151e0fd 20 ledred=!ledred;
MatthewMaat 3:46c11151e0fd 21 }
MatthewMaat 3:46c11151e0fd 22 else if (c=='g')
MatthewMaat 3:46c11151e0fd 23 {
MatthewMaat 3:46c11151e0fd 24 ledgreen=!ledgreen;
MatthewMaat 3:46c11151e0fd 25 }
MatthewMaat 3:46c11151e0fd 26 else if (c=='b')
MatthewMaat 3:46c11151e0fd 27 {
MatthewMaat 3:46c11151e0fd 28 ledblue=!ledblue;
MatthewMaat 3:46c11151e0fd 29 }
MatthewMaat 3:46c11151e0fd 30 else
MatthewMaat 3:46c11151e0fd 31 {
MatthewMaat 3:46c11151e0fd 32 ledred=1;
MatthewMaat 3:46c11151e0fd 33 ledgreen=1;
MatthewMaat 3:46c11151e0fd 34 ledblue=1;
MatthewMaat 3:46c11151e0fd 35 }
MatthewMaat 3:46c11151e0fd 36 }
RobertoO 0:67c50348f842 37
RobertoO 0:67c50348f842 38 int main()
RobertoO 0:67c50348f842 39 {
MatthewMaat 3:46c11151e0fd 40 ledred=1;
MatthewMaat 3:46c11151e0fd 41 ledgreen=1;
MatthewMaat 3:46c11151e0fd 42 ledblue=1;
MatthewMaat 3:46c11151e0fd 43 Theticker.attach(Take_Measurement,0.05);
MatthewMaat 3:46c11151e0fd 44 int countr;
RobertoO 0:67c50348f842 45 pc.baud(115200);
RobertoO 1:b862262a9d14 46 pc.printf("\r\nStarting...\r\n\r\n");
MatthewMaat 3:46c11151e0fd 47 pc.printf("Enter the color that has to blink:\r\n");
MatthewMaat 3:46c11151e0fd 48 c=pc.getc();
MatthewMaat 3:46c11151e0fd 49 pc.printf("Color picked: '%c'\r\nNow counting so the system does something:\r\n",c);
RobertoO 0:67c50348f842 50 while (true) {
MatthewMaat 2:626688c21b6f 51 color+=1;
MatthewMaat 3:46c11151e0fd 52 pc.printf("%i\r\n",countr);
RobertoO 0:67c50348f842 53 wait_ms(500);
RobertoO 0:67c50348f842 54 }
RobertoO 0:67c50348f842 55 }