arduino instrument – Kevin Gulling http://www.kevingulling.com Game Development, VR, and more Mon, 19 Dec 2016 02:25:09 +0000 en-US hourly 1 https://wordpress.org/?v=5.9.13 81085834 12 Days of Arduino – Day 5 – Photoresistor Pitch Slide/Bend Keyduino https://kevingulling.com/2016/12/12-days-arduino-day-5-photoresistor-pitch-slidebend-keyduino/ Sat, 17 Dec 2016 17:55:32 +0000 https://kevingulling.com/?p=1304 Hello again and a warm welcome to my series “12 Days of Arduino” Day 5. Today we use a photoresistor to alter the pitch of our tone, effectively enabling us to reach every single note, making this a truly practical instrument of 8 bit glory! Project requires –Arduino Uno –Active buzzer –3x button touch switch […]

The post 12 Days of Arduino – Day 5 – Photoresistor Pitch Slide/Bend Keyduino appeared first on Kevin Gulling - Game Development, VR, and more.

]]>
arduino day5
Hello again and a warm welcome to my series “12 Days of Arduino” Day 5. Today we use a photoresistor to alter the pitch of our tone, effectively enabling us to reach every single note, making this a truly practical instrument of 8 bit glory!



Project requires
–Arduino Uno
–Active buzzer
–3x button touch switch
-220 ohm resistor
-4x 10k ohm resistor
-2x 220 ohm resistor
-Jumper wires
-Tip120
-SN74HC595
-Photoresistor

I know it’s hard to see the circuitry in the video, things are starting to get crowded. Maybe I’ll upload a diagram if I get some time after the series is complete.

Photoresistor sketch

Photoresistor Sound FX Sketch

//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;
int number = 1;
int speakerPin = 6;
//Buttons
int button1Pin = 2;
int button2Pin = 3;
int button3Pin = 4;
int photoresistorPin = A0;
int sensorValue = 0;

void setup() {
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(speakerPin, OUTPUT);
pinMode(button1Pin, INPUT);
pinMode(button2Pin, INPUT);
pinMode(button3Pin, INPUT);
}

void loop() {

if(digitalRead(button1Pin) == HIGH){
sensorValue = analogRead(photoresistorPin);
tone(speakerPin, 790 +(sensorValue*2));//A5
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, number);
digitalWrite(latchPin, HIGH);
delay(10);
number++;
}

else if(digitalRead(button2Pin) == HIGH){
sensorValue = analogRead(photoresistorPin);
tone(speakerPin, 1750 +(sensorValue*2));//A6
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, number);
digitalWrite(latchPin, HIGH);
delay(10);
number++;
}

else if(digitalRead(button3Pin) == HIGH){
sensorValue = analogRead(photoresistorPin);
tone(speakerPin, 3510+(sensorValue*2));//A7
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, number);
digitalWrite(latchPin, HIGH);
delay(10);
number++;

}

else{
number = 0;
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, number);
digitalWrite(latchPin, HIGH);
delay(10);
}

}

If you aren’t a registered member of KevinGulling.com, and don’t want to register, feel free to comment on the YouTube video, I read those as well.

Visit ICStation.com for the best prices on sensors:


The post 12 Days of Arduino – Day 5 – Photoresistor Pitch Slide/Bend Keyduino appeared first on Kevin Gulling - Game Development, VR, and more.

]]>
1304
12 Days of Arduino – Day 4 – Tremolo FX With Shift Register https://kevingulling.com/2016/12/12-days-of-arduino-day-4-tremolo-fx-with-shift-register/ https://kevingulling.com/2016/12/12-days-of-arduino-day-4-tremolo-fx-with-shift-register/#comments Fri, 16 Dec 2016 19:31:58 +0000 https://kevingulling.com/?p=1284 Welcome back to day 4 of 12 days of Arduino! I’m glad you’ve been following this far, things are about to get exciting! Today I take the keyboard and using a SN74HC595 Texas Instruments Shift Register I create a tremolo effect Project requires –Arduino Uno –Active buzzer –3x button touch switch -220 ohm resistor -3x […]

The post 12 Days of Arduino – Day 4 – Tremolo FX With Shift Register appeared first on Kevin Gulling - Game Development, VR, and more.

]]>
shift register tremolo

Welcome back to day 4 of 12 days of Arduino! I’m glad you’ve been following this far, things are about to get exciting! Today I take the keyboard and using a SN74HC595 Texas Instruments Shift Register I create a tremolo effect



Project requires
–Arduino Uno
–Active buzzer
–3x button touch switch
-220 ohm resistor
-3x 10k ohm resistor
-220 ohm resistor
-Jumper wires
-Tip120
-SN74HC595

SN74HC595 Shift Register datasheet.
Tip 120 datasheet from adafruit.

arduino keyboard with tremelo

Keyboard with Tremolo Sketch


//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;

int number = 1;
int speakerPin = 6;

//Buttons
int button1Pin = 2;
int button2Pin = 3;
int button3Pin = 4;

void setup() {
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(speakerPin, OUTPUT);
pinMode(button1Pin, INPUT);
pinMode(button2Pin, INPUT);
pinMode(button3Pin, INPUT);

}

void loop() {
if(digitalRead(button1Pin) == HIGH){
tone(speakerPin, 1000);
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, number);
digitalWrite(latchPin, HIGH);
delay(10);
number++;
}
else if(digitalRead(button2Pin) == HIGH){
tone(speakerPin, 2000);
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, number);
digitalWrite(latchPin, HIGH);
delay(10);
number++;
}
else if(digitalRead(button3Pin) == HIGH){
tone(speakerPin, 3000);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, number);
digitalWrite(latchPin, HIGH);
delay(10);
number++;
}
else{
number = 0;
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, number);
digitalWrite(latchPin, HIGH);
delay(10);
}

}

One thing to note here is that MSBFIRST means “most significant bit first” and LSBFIRST means “least significant bit first”. We want to use MSBFIRST to accomplish this effect. Basically what’s happening here is we increment 0 by 1 each time the loop is ran and as a result we have an alternating effect on pin 1 of the shift register. A cleaner way to run this would be to increment by 1 and then subtract by 1, but really this is all pointless in the first place, it’s definitely a “Rube Goldberg” way of going about this since you could simply program it with code, but there are opportunities here to utilize 7 more pins, so maybe tomorrow I can make this into something “practical” (I use this term loosely!) and utilize more of the 8 bits of memory we can store here! The possibilities are endless, exciting!

Here’s a tutorial for ShiftOut I highly recommend if you are getting started with shift registers!

Please check out the sponsor of this series:


The post 12 Days of Arduino – Day 4 – Tremolo FX With Shift Register appeared first on Kevin Gulling - Game Development, VR, and more.

]]>
https://kevingulling.com/2016/12/12-days-of-arduino-day-4-tremolo-fx-with-shift-register/feed/ 1 1284
12 Days of Arduino – Day 3 – Pitch Shift and LED FX https://kevingulling.com/2016/12/12-days-arduino-day-3-pitch-shift-led-fx/ https://kevingulling.com/2016/12/12-days-arduino-day-3-pitch-shift-led-fx/#comments Thu, 15 Dec 2016 21:34:46 +0000 https://kevingulling.com/?p=1273 Hi and welcome back to “12 Days of Arduino”, Day 3! On the third day of Arduino Kevin gave to thee: Arduino Piano/Keyboard Pitch Shifter Sort of like a whammy bar! Makes a fantastic 8 bit horror effect! If you read from day 1 – (Arduino Morse Code Keyer) you can see the simple progression […]

The post 12 Days of Arduino – Day 3 – Pitch Shift and LED FX appeared first on Kevin Gulling - Game Development, VR, and more.

]]>
12 days of arduino day 3

Hi and welcome back to “12 Days of Arduino”, Day 3! On the third day of Arduino Kevin gave to thee:

Arduino Piano/Keyboard Pitch Shifter



Sort of like a whammy bar! Makes a fantastic 8 bit horror effect!

If you read from day 1 – (Arduino Morse Code Keyer) you can see the simple progression that lead to this point.


Project requires

–Arduino Uno
–Active buzzer
–4x button touch switch
-RGB LED
-220 ohm resistor
-4x 10k ohm resistor
-220 ohm resistor
-Jumper wires
-Ball switch

The sketch:

Pitch Shift Sketch


int switchPin1 = 2;
int switchPin2 = 4;
int switchPin3 = 7;
int switchPin4 = 8;
int tiltSwitch = 9;
int ledPin = 13;
int ledPinG = 12;
int ledPinB = 10;
int speakerPin = 11;
int lowA = 880;
int lowBb = 932;
int lowB = 988;
int C = 1046;
int D = 1175;
int E = 1319;
int F = 1396;
int G = 1567;
int A = 1760;
int B = 1976;
int wa = 25;

void setup() {
// put your setup code here, to run once:
pinMode(switchPin1, INPUT);
pinMode(switchPin2, INPUT);
pinMode(switchPin3, INPUT);
pinMode(switchPin4, INPUT);
pinMode(tiltSwitch, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(ledPinG, OUTPUT);
pinMode(ledPinB, OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(switchPin1) == HIGH){
digitalWrite(ledPin, HIGH);
if(digitalRead(tiltSwitch) == HIGH){
tone(speakerPin, lowA-wa);
}
else{
tone(speakerPin, lowA);
}

}
else if(digitalRead(switchPin2) == HIGH){
digitalWrite(ledPin, HIGH);
digitalWrite(ledPinG, HIGH);
if(digitalRead(tiltSwitch) == HIGH){
tone(speakerPin, lowBb-wa);
}
else{
tone(speakerPin, lowBb);
}
}
else if(digitalRead(switchPin3) == HIGH){
digitalWrite(ledPinB, HIGH);
if(digitalRead(tiltSwitch) == HIGH){
tone(speakerPin, C-wa);
}
else{
tone(speakerPin, C);
}
}
else if(digitalRead(switchPin4) == HIGH){
digitalWrite(ledPinG, HIGH);
if(digitalRead(tiltSwitch) == HIGH){
tone(speakerPin, E-wa);
}
else{
tone(speakerPin, E);
}
}
else{
digitalWrite(ledPin, LOW);
digitalWrite(ledPinG, LOW);
digitalWrite(ledPinB, LOW);
noTone(speakerPin);
}

}

I made some minor alterations along with the new additions.

A tilt switch is a simple component. A ball switch is a more specific type of tilt switch, similar to amercury switch only using a metal ball that rolls up and down the cylinder and connects to two contacts to open and close the circuit. Let’s see if I can ascii art an example 😉

╬ ╬
║0║
╚-╝
When upright, ball sits on bottom, contacts are open
╔-╗
║ ║
╬0╬
When tilted the metallic ball hits both of the contacts, closing the circuit

If that didn’t do it for you, you can find a datasheet here.

Please check out the sponsor of this series:


Day 4 →

The post 12 Days of Arduino – Day 3 – Pitch Shift and LED FX appeared first on Kevin Gulling - Game Development, VR, and more.

]]>
https://kevingulling.com/2016/12/12-days-arduino-day-3-pitch-shift-led-fx/feed/ 1 1273