Marco Peciola
/
Marco Peciola MBED
My personal projects
main.cpp
- Committer:
- macez
- Date:
- 2021-01-19
- Revision:
- 0:ecd984e9f637
File content as of revision 0:ecd984e9f637:
/* mbed Microcontroller Library * Copyright (c) 2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 */ #include "mbed.h" // Blinking rate in milliseconds #define BLINKING_RATE 500ms int main() { // Initialise the digital pin LED1 as an output float x = 0.0f; AnalogIn volume(p15); DigitalOut ledone(LED1); DigitalOut ledtwo(LED2); DigitalOut ledthree(LED3); DigitalOut ledfour(LED4); while (true) { x = volume.read() if (x<0.25){ ledone.write(1) } else if ((x >= 0.25) (&& x< 0.5)){ ledotwo.write(1) } else if((x >= 0.5) (&& x<0.75)){ ledthree.write(1) } else(x>0.75){ ledfour.write(1) } ThisThread::sleep_for(5s); } }