Skip to content

Instantly share code, notes, and snippets.

@rocketjosh
Created February 22, 2021 20:55
Show Gist options
  • Save rocketjosh/fd463382740bf074b0277dd6110e2cd3 to your computer and use it in GitHub Desktop.
Save rocketjosh/fd463382740bf074b0277dd6110e2cd3 to your computer and use it in GitHub Desktop.
#include <M2_12VIO.h>
M2_12VIO M2IO; //Constructor for the M2_12Vio library
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
void setup() {
M2IO.Init_12VIO(); // Initialise the M2I/O library
SerialUSB.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
M2IO.Setpin_12VIO(2, ON, SOURCE, PWM_PIN, 100, 10); // Turn the output ON. Used for demonstrating I/O Pins with LEDS connected to M2 I/O pins
M2IO.Change_Frequency_12VIO(2, brightness);
//analogWrite(led, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0 || brightness >= 555) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming effect
SerialUSB.println(brightness);
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment