Author: FUJIKEN
Original Location: http://japan.renesasrulz.com/gr_user_forum_japanese/f/4/t/645.aspx
------------------------------------------------------
I made a Thereminvox-like sound instrument with GR-SAKURA and GP2Y0A31 (Sharp's Infrared distance sensor). GR-SAKURA generates a musical scale based on distance. You need to use your hand to reflect IR-light from 5cm to 30cm.
Demo Video:http://www.youtube.com/watch?v=MNwCbkaP7dc&feature=youtu.be
/*GR-SAKURA Sketch Template Version: V1.00*/
#include <rxduino.h>
#define A0 14
#define speaker 8
int a;
void setup()
{
//Serial.begin(38400);
pinMode(A0, INPUT);
}
void loop()
a = analogRead(A0) ;
Serial.println(a);
if ((a>550) && (a<700)) {
Serial.println("5cm ド"); // 5cm Do
tone(speaker,262);
delay(2000);
noTone(speaker);
else if ((a>450) && (a<540)) {
Serial.println("7cm レ"); // 7cm Re
tone(speaker,294);
else if ((a>400)&&(a<440)) {
Serial.println("10cm ミ"); // 10cm Mi
tone(speaker,330);
else if ((a>330)&&(a<390)) {
Serial.println("12cm ファ"); // 12cm Fa
tone(speaker,349);
else if ((a>250)&&(a<320)) {
Serial.println("15cm ソ"); // 15cm Sol
tone(speaker,392);
else if ((a>210)&&(a<240)) {
Serial.println("20cm ラ"); // 20cm La
tone(speaker,440);
else if ((a>150) && (a<200)) {
Serial.println("30cm シ"); // 30cm Ti
tone(speaker,494);
else if ((a>100) && (a<140)) {
Serial.println("40cm 高いド"); // 40cm High-Do
tone(speaker,523);
This is a clever use of a Sakura board
Mike Clements
RenesasRulz Moderator