Commit a5112ce0ddfdb7041b2e50142290d85561057588
1 parent
ed7f6a73
Exists in
master
A starting point for programming the telementry transmitter. Generates a sine wa…
…ve, which could be useful in the absence of real sensors to test with
Showing
1 changed file
with
27 additions
and
0 deletions
Show diff stats
| @@ -0,0 +1,27 @@ | @@ -0,0 +1,27 @@ | ||
| 1 | +/* | ||
| 2 | + * Hello, World! | ||
| 3 | + * | ||
| 4 | + * A starting point for programming a robot monitoring system | ||
| 5 | + * By the UoN Robot Wars project, 2018 | ||
| 6 | + * This code is under the GPL | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | +#include <math.h> | ||
| 10 | + | ||
| 11 | +void setup() { | ||
| 12 | + Serial.begin(9600); | ||
| 13 | + Serial.println("Hello, World"); | ||
| 14 | + pinMode(13, OUTPUT); | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +void loop() { | ||
| 18 | + // PWM an LED, fading sinusoidally | ||
| 19 | + double major_frequency = 0.3; | ||
| 20 | + double minor_frequency = 100; | ||
| 21 | + double duty = 0.5+(0.5*sin(2*PI*major_frequency*millis()/1000)); | ||
| 22 | + Serial.println(duty); | ||
| 23 | + digitalWrite(13, HIGH); | ||
| 24 | + delay(1000 * duty/minor_frequency); | ||
| 25 | + digitalWrite(13, LOW); | ||
| 26 | + delay(1000 * (1-duty)/minor_frequency); | ||
| 27 | +} |