test2

Dependencies:   mbed

Fork of Nucleo_blink_led1 by yellow bee

Committer:
yellowBee
Date:
Tue Sep 06 07:48:51 2016 +0000
Revision:
1:33d68bd4c493
Parent:
0:9d596b5ec030
123

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yellowBee 0:9d596b5ec030 1 #include "mbed.h"
yellowBee 0:9d596b5ec030 2
yellowBee 0:9d596b5ec030 3
yellowBee 0:9d596b5ec030 4 /*
yellowBee 0:9d596b5ec030 5 DigitalOut myled(LED1);
yellowBee 0:9d596b5ec030 6
yellowBee 0:9d596b5ec030 7 int main()
yellowBee 0:9d596b5ec030 8 {
yellowBee 0:9d596b5ec030 9 while(1) {
yellowBee 0:9d596b5ec030 10 myled = 1; // LED is ON
yellowBee 0:9d596b5ec030 11 wait(0.2); // 200 ms
yellowBee 0:9d596b5ec030 12 myled = 0; // LED is OFF
yellowBee 0:9d596b5ec030 13 wait(1.0); // 1 sec
yellowBee 0:9d596b5ec030 14 }
yellowBee 0:9d596b5ec030 15 }
yellowBee 0:9d596b5ec030 16
yellowBee 0:9d596b5ec030 17
yellowBee 0:9d596b5ec030 18 Serial pc(USBTX, USBRX); // tx, rx
yellowBee 0:9d596b5ec030 19
yellowBee 0:9d596b5ec030 20 int main() {
yellowBee 0:9d596b5ec030 21 pc.printf("Hello World!\n");
yellowBee 0:9d596b5ec030 22 while(1);
yellowBee 0:9d596b5ec030 23 }
yellowBee 0:9d596b5ec030 24
yellowBee 0:9d596b5ec030 25
yellowBee 0:9d596b5ec030 26
yellowBee 0:9d596b5ec030 27 Serial pc(USBTX, USBRX);
yellowBee 0:9d596b5ec030 28
yellowBee 0:9d596b5ec030 29 int main() {
yellowBee 0:9d596b5ec030 30 pc.printf("Echoes back to the screen anything you type\n");
yellowBee 0:9d596b5ec030 31 while(1) {
yellowBee 0:9d596b5ec030 32 pc.putc(pc.getc());
yellowBee 0:9d596b5ec030 33 }
yellowBee 0:9d596b5ec030 34 }
yellowBee 0:9d596b5ec030 35
yellowBee 0:9d596b5ec030 36 */
yellowBee 0:9d596b5ec030 37
yellowBee 0:9d596b5ec030 38 Serial pc(USBTX, USBRX); // tx, rx
yellowBee 0:9d596b5ec030 39 PwmOut led(LED1);
yellowBee 0:9d596b5ec030 40
yellowBee 0:9d596b5ec030 41 float brightness = 0.0;
yellowBee 0:9d596b5ec030 42
yellowBee 0:9d596b5ec030 43 int main() {
yellowBee 0:9d596b5ec030 44 pc.printf("Press 'u' to turn LED1 brightness up, 'd' to turn it down\n");
yellowBee 0:9d596b5ec030 45
yellowBee 0:9d596b5ec030 46 while(1) {
yellowBee 0:9d596b5ec030 47 char c = pc.getc();
yellowBee 0:9d596b5ec030 48 if((c == 'u') && (brightness < 0.5)) {
yellowBee 0:9d596b5ec030 49 brightness += 0.01;
yellowBee 0:9d596b5ec030 50 led = brightness;
yellowBee 0:9d596b5ec030 51 }
yellowBee 0:9d596b5ec030 52 if((c == 'd') && (brightness > 0.0)) {
yellowBee 0:9d596b5ec030 53 brightness -= 0.01;
yellowBee 0:9d596b5ec030 54 led = brightness;
yellowBee 0:9d596b5ec030 55 }
yellowBee 0:9d596b5ec030 56 }
yellowBee 1:33d68bd4c493 57
yellowBee 1:33d68bd4c493 58
yellowBee 1:33d68bd4c493 59
yellowBee 0:9d596b5ec030 60 }