Skip to content

Instantly share code, notes, and snippets.

/* This sketch is heavily based on a demo code by
[Angelo qiao](Angelo.qiao@dfrobot.com) for DFRobot,
but it replaces the function that plays a new mp3 file after
a set period of time with a function that plays a new mp3
file when triggered by an external sensor, either a PIR,
doppler radar, or even a button*/
/***************************************************
DFPlayer - A Mini MP3 Player For Arduino
<https://www.dfrobot.com/product-1121.html>
int steppin = 3;
int dirpin = 2;
int stepdelay;
int speed_value;
int direction_value;
void setup() {
pinMode(steppin, OUTPUT);
pinMode(dirpin, OUTPUT);
digitalWrite(dirpin, LOW); // direction pin either LOW or HIGH to move in either direction.
Serial.begin(115200);
#!/usr/bin/env python2
import gpiozero
import sys
import os
from subprocess import Popen
import time
import random
movie1 = ("/home/pi/Videos/video1.mp4")
movie2 = ("/home/pi/Videos/video2.mp4")
/*
* Portions of this code are adapted from Aurora: https://github.com/pixelmatix/aurora
* Copyright (c) 2014 Jason Coon
*
* Portions of this code are adapted from LedEffects Plasma by Robert Atkins: https://bitbucket.org/ratkins/ledeffects/src/26ed3c51912af6fac5f1304629c7b4ab7ac8ca4b/Plasma.cpp?at=default
* Copyright (c) 2013 Robert Atkins
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
import RPi.GPIO as GPIO
import sys
import os
from subprocess import Popen
import time
import random
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
movie1 = ("/home/pi/Videos/video1.mp4")
import RPi.GPIO as GPIO
import sys
import os
from subprocess import Popen
import time
import random
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
movie1 = ("/home/pi/Videos/video1.mp4")
/*
This sketch allows an Arduino to act as a speedometer. Data input can come from
magnets glued to the rim or spoke of a wheel along with a hall-effect sensor or
reed switch. You can also use an optical sensor using the spokes to break the
beam of light.
(If you use a reed switch instead of a hall-effect sensor, you will probably
need to modify the sketch to include some debouncing. If you use an optical
sensor, you might need Schmitt trigger circuitry.)