Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@0:366ff44cdee8, 2016-11-03 (annotated)
- Committer:
- papuxtream
- Date:
- Thu Nov 03 06:50:30 2016 +0000
- Revision:
- 0:366ff44cdee8
brightness control of led by PWM Technic
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| papuxtream | 0:366ff44cdee8 | 1 | #include "mbed.h" |
| papuxtream | 0:366ff44cdee8 | 2 | DigitalIn ButtonUp(p5,PullUp); |
| papuxtream | 0:366ff44cdee8 | 3 | DigitalIn ButtonDown(p6,PullUp); |
| papuxtream | 0:366ff44cdee8 | 4 | PwmOut led(p26); |
| papuxtream | 0:366ff44cdee8 | 5 | int val=0; |
| papuxtream | 0:366ff44cdee8 | 6 | int main() { |
| papuxtream | 0:366ff44cdee8 | 7 | while(1) { |
| papuxtream | 0:366ff44cdee8 | 8 | if((ButtonUp==1)&&(val<255)) |
| papuxtream | 0:366ff44cdee8 | 9 | {wait_ms(10); |
| papuxtream | 0:366ff44cdee8 | 10 | val++;} |
| papuxtream | 0:366ff44cdee8 | 11 | else if((ButtonDown==1)&&(val>0)) |
| papuxtream | 0:366ff44cdee8 | 12 | {wait_ms(10); |
| papuxtream | 0:366ff44cdee8 | 13 | val--;} |
| papuxtream | 0:366ff44cdee8 | 14 | val=led; |
| papuxtream | 0:366ff44cdee8 | 15 | } |
| papuxtream | 0:366ff44cdee8 | 16 | } |