MCPcopy Create free account
hub / github.com/DexterInd/GoPiGo3 / main

Function main

Software/C/Examples/grove_led.cpp:31–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29void exit_signal_handler(int signo);
30
31int main(){
32 signal(SIGINT, exit_signal_handler); // register the exit function for Ctrl+C
33
34 GPG.detect(); // Make sure that the GoPiGo3 is communicating and that the firmware is compatible with the drivers.
35
36 GPG.set_grove_type(GROVE_1, GROVE_TYPE_CUSTOM);
37 GPG.set_grove_mode(GROVE_1_1, OUTPUT_PWM);
38
39 int8_t i = 0;
40 int8_t a = 1;
41 while(true){
42 GPG.set_grove_pwm_duty(GROVE_1_1, i);
43 i += a;
44 if(i == 100 || i == 0){
45 a *= -1;
46 }
47 usleep(5000);
48 }
49}
50
51// Signal handler that will be called when Ctrl+C is pressed to stop the program
52void exit_signal_handler(int signo){

Callers

nothing calls this directly

Calls 4

detectMethod · 0.80
set_grove_typeMethod · 0.45
set_grove_modeMethod · 0.45
set_grove_pwm_dutyMethod · 0.45

Tested by

no test coverage detected