Devices & Components
Arduino Uno Rev3
Bluno M3
Jumper wires (generic)
LED (generic)
Resistor 220 ohm
Microphone Sound Sensor KY-038 Module
SG90 Micro-servo motor
Hardware & Tools
Hot glue gun (generic)
Multitool, Screwdriver
Software & Tools
Arduino IDE
Project description
Code
Bluno_M3_Arduino_Drum_Lessons.ino
arduino
1/* 2 * Version 1.0 August, 2021 3 * Copyright (c) 2021 Korneel Verraes 4 * https://lego-projecten.webnode.nl/ 5 * 6 * Bluno M3 Arduino Drum Lessons: 7 * A sound sensor with digital output is connected to pin 7 8 * A servo motor is connected to pin 9 9 * An LED is connected to pin 13 10 * 11 * Accompanying video: https://youtu.be/OXwlFxWnDI8 12 */ 13 14#include <ServoM3.h> //use this on Bluno M3 15//#include <Servo.h> //use this on other Arduino boards (e.g.: Arduino UNO, Arduino MEGA...) 16 17Servo servo; 18 19int clapCount = 0; 20int clapTime[50]; 21int led = 13; 22int sensor = 7; 23boolean clap = 0; 24 25void setup() { 26 servo.attach(9); 27 servo.write(0); 28 pinMode(led, OUTPUT); 29 pinMode(sensor, INPUT); 30} 31 32void loop() { 33 clap = digitalRead(sensor); 34 if (clap == 1) { 35 digitalWrite(led, HIGH); 36 clapTime[clapCount] = millis(); 37 clapCount++; 38 delay(200); 39 } 40 else { 41 digitalWrite(led, LOW); 42 } 43 if ((millis() - clapTime[clapCount - 1]) > 2000 && clapCount != 0) { 44 for (int i = 1; i < clapCount ; i++) { 45 servo.write(13); 46 delay(80); 47 servo.write(0); 48 delay (clapTime[i] - clapTime[i - 1] - 80); 49 } 50 servo.write(13); 51 delay(80); 52 servo.write(0); 53 delay(800); 54 clapCount = 0; 55 } 56} 57
Downloadable files
Schematic for Bluno M3 Drum Lessons
Schematic for Bluno M3 Drum Lessons

Schematic for Bluno M3 Drum Lessons
Schematic for Bluno M3 Drum Lessons

Comments
Only logged in users can leave comments