Skip to content

Instantly share code, notes, and snippets.

@Lif3line
Lif3line / btWake.c
Last active February 6, 2024 12:57
Arduino code to wake up upon interrupt from a bluetooth module and toggle a pin each time (here controlling a relay hence relayPin).
#include <avr/sleep.h>
#include <SoftwareSerial.h>
SoftwareSerial blueSerial(3, 9); // RX, TX pins
int relayActive = false;
int relayPin = 7;
void setup() {
blueSerial.begin(9600); // Set baud rate
pinMode(relayPin, OUTPUT);
@jimsynz
jimsynz / rgb_spectrum.c
Created January 5, 2011 20:59
Arduino sketch to cycle an RGB LED through the colour spectrum.
const int redPin = 11;
const int greenPin = 10;
const int bluePin = 9;
void setup() {
// Start off with the LED off.
setColourRgb(0,0,0);
}
void loop() {
/* Sleep Demo Serial
* -----------------
* Example code to demonstrate the sleep functions in a Arduino. Arduino will wake up
* when new data is received in the serial port USART
* Based on Sleep Demo Serial from http://www.arduino.cc/playground/Learning/ArduinoSleepCode
*
* Copyright (C) 2006 MacSimski 2006-12-30
* Copyright (C) 2007 D. Cuartielles 2007-07-08 - Mexico DF
*
* With modifications from Ruben Laguna 2008-10-15