Servo script + magnet driver for biorobotics project in Uni. Made by Teun van der Molen
Dependencies: MODSERIAL Servo mbed
main.cpp@0:05ecf16dcb7b, 2015-09-09 (annotated)
- Committer:
- teunman
- Date:
- Wed Sep 09 15:19:24 2015 +0000
- Revision:
- 0:05ecf16dcb7b
- Child:
- 1:26baa438620b
Just the HIDscope test thing;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
teunman | 0:05ecf16dcb7b | 1 | #include "mbed.h" |
teunman | 0:05ecf16dcb7b | 2 | #include "HIDScope.h" |
teunman | 0:05ecf16dcb7b | 3 | |
teunman | 0:05ecf16dcb7b | 4 | // Define the HIDScope and Ticker object |
teunman | 0:05ecf16dcb7b | 5 | HIDScope scope(1); |
teunman | 0:05ecf16dcb7b | 6 | Ticker scopeTimer; |
teunman | 0:05ecf16dcb7b | 7 | |
teunman | 0:05ecf16dcb7b | 8 | // Read the analog input |
teunman | 0:05ecf16dcb7b | 9 | AnalogIn an_in(A0); |
teunman | 0:05ecf16dcb7b | 10 | |
teunman | 0:05ecf16dcb7b | 11 | // The data read and send function |
teunman | 0:05ecf16dcb7b | 12 | void scopeSend() |
teunman | 0:05ecf16dcb7b | 13 | { |
teunman | 0:05ecf16dcb7b | 14 | scope.set(0,an_in.read()); |
teunman | 0:05ecf16dcb7b | 15 | scope.send(); |
teunman | 0:05ecf16dcb7b | 16 | } |
teunman | 0:05ecf16dcb7b | 17 | |
teunman | 0:05ecf16dcb7b | 18 | int main() |
teunman | 0:05ecf16dcb7b | 19 | { |
teunman | 0:05ecf16dcb7b | 20 | // Attach the data read and send function at 100 Hz |
teunman | 0:05ecf16dcb7b | 21 | scopeTimer.attach_us(&scopeSend, 1e4); |
teunman | 0:05ecf16dcb7b | 22 | |
teunman | 0:05ecf16dcb7b | 23 | while(1) { } |
teunman | 0:05ecf16dcb7b | 24 | } |