안녕하세요 아두이노 초보 학생입니다.
우연히 검색중 이 사이트를 알게되어 공부하여 프로젝트를 진행하고있습니다.
진행중인 프로젝트는 런치패드를 모방한 악기(?)인데요.
위 사진입니다 헤헤
만들고자하는 악기의 알고리즘은 버튼을 누르면 LED가 점등하고
버튼의 HIGH LOW 값을 아두이노가 스케치를 통해 프로세싱에 값을 전송하고
프로세싱은 해당 버튼의 음원을 재생하는 그런 시스템인데요...
위 사진은 하드웨어 이고, 스케치 프로그램 까지 완료되어있는 상태입니다.
프로세싱에 대한 정보가 하나도 없어 어려움을 겪고 있습니다....
-스케치 코드
void setup() {
Serial.begin(9600);
//LED 10개
pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
pinMode(11,OUTPUT);
pinMode(10,OUTPUT);
pinMode(9,OUTPUT);
pinMode(8,OUTPUT);
pinMode(7,OUTPUT);
pinMode(6,OUTPUT);
pinMode(5,OUTPUT);
pinMode(4,OUTPUT);
//버튼 36개
pinMode(18,INPUT);
pinMode(19,INPUT);
pinMode(20,INPUT);
pinMode(21,INPUT);
pinMode(22,INPUT);
pinMode(23,INPUT);
pinMode(24,INPUT);
pinMode(25,INPUT);
pinMode(26,INPUT);
pinMode(27,INPUT);
pinMode(28,INPUT);
pinMode(29,INPUT);
pinMode(30,INPUT);
pinMode(31,INPUT);
pinMode(32,INPUT);
pinMode(33,INPUT);
pinMode(34,INPUT);
pinMode(35,INPUT);
pinMode(36,INPUT);
pinMode(37,INPUT);
pinMode(38,INPUT);
pinMode(39,INPUT);
pinMode(40,INPUT);
pinMode(41,INPUT);
pinMode(42,INPUT);
pinMode(43,INPUT);
pinMode(44,INPUT);
pinMode(45,INPUT);
pinMode(46,INPUT);
pinMode(47,INPUT);
pinMode(48,INPUT);
pinMode(49,INPUT);
pinMode(50,INPUT);
pinMode(51,INPUT);
pinMode(52,INPUT);
pinMode(53,INPUT);
digitalWrite(18,LOW);
digitalWrite(19,LOW);
digitalWrite(20,LOW);
digitalWrite(21,LOW);
digitalWrite(22,LOW);
digitalWrite(23,LOW);
digitalWrite(24,LOW);
digitalWrite(25,LOW);
digitalWrite(26,LOW);
digitalWrite(27,LOW);
digitalWrite(28,LOW);
digitalWrite(29,LOW);
digitalWrite(30,LOW);
digitalWrite(31,LOW);
digitalWrite(32,LOW);
digitalWrite(33,LOW);
digitalWrite(34,LOW);
digitalWrite(35,LOW);
digitalWrite(36,LOW);
digitalWrite(37,LOW);
digitalWrite(38,LOW);
digitalWrite(39,LOW);
digitalWrite(40,LOW);
digitalWrite(41,LOW);
digitalWrite(42,LOW);
digitalWrite(43,LOW);
digitalWrite(44,LOW);
digitalWrite(45,LOW);
digitalWrite(46,LOW);
digitalWrite(47,LOW);
digitalWrite(48,LOW);
digitalWrite(49,LOW);
digitalWrite(50,LOW);
digitalWrite(51,LOW);
digitalWrite(52,LOW);
digitalWrite(53,LOW);
}
void loop() {
//프로세싱에 전송할 버튼의 디지털신호를 저장할 변수
int b1 = 0, b2 = 0, b3 = 0, b4 = 0, b5 = 0, b6 = 0, b7 = 0, b8 = 0, b9 = 0, b10 = 0, b11 = 0, b12 = 0, b13 = 0, b14 = 0, b15 = 0, b16 = 0;
int b17 = 0, b18 = 0, b19 = 0, b20 = 0, b21 = 0, b22 = 0, b23 = 0, b24 = 0, b25 = 0, b26 = 0, b27 = 0, b28 = 0, b29 = 0, b30 = 0;
int b31 = 0, b32 = 0, b33 = 0, b34 = 0, b35 = 0, b36 = 0;
//LED 변수
int led;
//버튼 1
if(digitalRead(48) == HIGH)
{
led = 250;
b1 = 1;
digitalWrite(48,LOW);
}
else if(digitalRead(48) == LOW)
{
b1 = 0;
}
//버튼2
if(digitalRead(49) == HIGH)
{
led = 250;
b2 = 1;
digitalWrite(49,LOW);
}
else if(digitalRead(49) == LOW)
{
b2 = 0;
}
//버튼3
if(digitalRead(50) == HIGH)
{
led = 250;
b3 = 1;
digitalWrite(50,LOW);
}
else if(digitalRead(50) == LOW)
{
b3 = 0;
}
//버튼4
if(digitalRead(51) == HIGH)
{
led = 250;
b4 = 1;
digitalWrite(51,LOW);
}
else if(digitalRead(51) == LOW)
{
b4 = 0;
}
//버튼5
if(digitalRead(52) == HIGH)
{
led = 250;
b5 = 1;
digitalWrite(52,LOW);
}
else if(digitalRead(52) == LOW)
{
b5 = 0;
}
//버튼6
if(digitalRead(53) == HIGH)
{
led = 250;
b6 = 1;
digitalWrite(53,LOW);
}
else if(digitalRead(53) == LOW)
{
b6 = 0;
}
//버튼7
if(digitalRead(42) == HIGH)
{
led = 250;
b7 = 1;
digitalWrite(42,LOW);
}
else if(digitalRead(42) == LOW)
{
b7 = 0;
}
//버튼8
if(digitalRead(43) == HIGH)
{
led = 250;
b8 = 1;
digitalWrite(43,LOW);
}
else if(digitalRead(43) == LOW)
{
b8 = 0;
}
//버튼9
if(digitalRead(44) == HIGH)
{
led = 250;
b9 = 1;
digitalWrite(44,LOW);
}
else if(digitalRead(44) == LOW)
{
b9 = 0;
}
//버튼10
if(digitalRead(45) == HIGH)
{
led = 250;
b10 = 1;
digitalWrite(45,LOW);
}
else if(digitalRead(45) == LOW)
{
b10 = 0;
}
//버튼11
if(digitalRead(46) == HIGH)
{
led = 250;
b11 = 1;
digitalWrite(46,LOW);
}
else if(digitalRead(46) == LOW)
{
b11 = 0;
}
//버튼12
if(digitalRead(47) == HIGH)
{
led = 250;
b12 = 1;
digitalWrite(47,LOW);
}
else if(digitalRead(47) == LOW)
{
b12 = 0;
}
//버튼13
if(digitalRead(36) == HIGH)
{
led = 250;
b13 = 1;
digitalWrite(36,LOW);
}
else if(digitalRead(36) == LOW)
{
b13 = 0;
}
//버튼14
if(digitalRead(37) == HIGH)
{
led = 250;
b14 = 1;
digitalWrite(37,LOW);
}
else if(digitalRead(37) == LOW)
{
b14 = 0;
}
//버튼15
if(digitalRead(39) == HIGH)
{
led = 250;
b15 = 1;
digitalWrite(39,LOW);
}
else if(digitalRead(39) == LOW)
{
b15 = 0;
}
//버튼16
if(digitalRead(38) == HIGH)
{
led = 250;
b16 = 1;
digitalWrite(38,LOW);
}
else if(digitalRead(38) == LOW)
{
b16 = 0;
}
//버튼17
if(digitalRead(40) == HIGH)
{
led = 250;
b17 = 1;
digitalWrite(40,LOW);
}
else if(digitalRead(40) == LOW)
{
b17 = 0;
}
//버튼18
if(digitalRead(41) == HIGH)
{
led = 250;
b18 = 1;
digitalWrite(41,LOW);
}
else if(digitalRead(41) == LOW)
{
b18 = 0;
}
//버튼19
if(digitalRead(30) == HIGH)
{
led = 250;
b19 = 1;
digitalWrite(30,LOW);
}
else if(digitalRead(30) == LOW)
{
b19 = 0;
}
//버튼20
if(digitalRead(31) == HIGH)
{
led = 250;
b20 = 1;
digitalWrite(31,LOW);
}
else if(digitalRead(31) == LOW)
{
b20 = 0;
}
//버튼21
if(digitalRead(32) == HIGH)
{
led = 250;
b21 = 1;
digitalWrite(32,LOW);
}
else if(digitalRead(32) == LOW)
{
b21 = 0;
}
//버튼22
if(digitalRead(33) == HIGH)
{
led = 250;
b22 = 1;
digitalWrite(33,LOW);
}
else if(digitalRead(33) == LOW)
{
b22 = 0;
}
//버튼23
if(digitalRead(34) == HIGH)
{
led = 250;
b23 = 1;
digitalWrite(34,LOW);
}
else if(digitalRead(34) == LOW)
{
b23 = 0;
}
//버튼24
if(digitalRead(35) == HIGH)
{
led = 250;
b24 = 1;
digitalWrite(35,LOW);
}
else if(digitalRead(35) == LOW)
{
b24 = 0;
}
//버튼25
if(digitalRead(24) == HIGH)
{
led = 250;
b25 = 1;
digitalWrite(24,LOW);
}
else if(digitalRead(24) == LOW)
{
b25 = 0;
}
//버튼26
if(digitalRead(25) == HIGH)
{
led = 250;
b26 = 1;
digitalWrite(25,LOW);
}
else if(digitalRead(25) == LOW)
{
b26 = 0;
}
//버튼27
if(digitalRead(26) == HIGH)
{
led = 250;
b27 = 1;
digitalWrite(26,LOW);
}
else if(digitalRead(26) == LOW)
{
b27 = 0;
}
//버튼28
if(digitalRead(27) == HIGH)
{
led = 250;
b28 = 1;
digitalWrite(27,LOW);
}
else if(digitalRead(27) == LOW)
{
b28 = 0;
}
//버튼29
if(digitalRead(28) == HIGH)
{
led = 250;
b29 = 1;
digitalWrite(28,LOW);
}
else if(digitalRead(28) == LOW)
{
b29 = 0;
}
//버튼30
if(digitalRead(29) == HIGH)
{
led = 250;
b30 = 1;
digitalWrite(29,LOW);
}
else if(digitalRead(29) == LOW)
{
b30 = 0;
}
//버튼31
if(digitalRead(18) == HIGH)
{
led = 250;
b31 = 1;
digitalWrite(18,LOW);
}
else if(digitalRead(18) == LOW)
{
b31 = 0;
}
//버튼32
if(digitalRead(19) == HIGH)
{
led = 250;
b32 = 1;
digitalWrite(19,LOW);
}
else if(digitalRead(19) == LOW)
{
b32 = 0;
}
//버튼33
if(digitalRead(20) == HIGH)
{
led = 250;
b33 = 1;
digitalWrite(20,LOW);
}
else if(digitalRead(20) == LOW)
{
b33 = 0;
}
//버튼34
if(digitalRead(21) == HIGH)
{
led = 250;
b34 = 1;
digitalWrite(21,LOW);
}
else if(digitalRead(21) == LOW)
{
b34 = 0;
}
//버튼35
if(digitalRead(22) == HIGH)
{
led = 250;
b35 = 1;
digitalWrite(22,LOW);
}
else if(digitalRead(22) == LOW)
{
b35 = 0;
}
//버튼36
if(digitalRead(23) == HIGH)
{
led = 250;
b36 = 1;
digitalWrite(23,LOW);
}
else if(digitalRead(23) == LOW)
{
b36 = 0;
}
//LED 제어
if(led>=5){
led-=5;
}
analogWrite(13,led);
analogWrite(12,led);
analogWrite(11,led);
analogWrite(10,led);
analogWrite(9,led);
analogWrite(8,led);
analogWrite(7,led);
analogWrite(6,led);
analogWrite(5,led);
analogWrite(4,led);
delay(10);
}
코드가 많이 더럽지요?.....
정상 작동 확인했습니다.
이제 프로세싱만 남았는데 도움을 얻고자 이렇게 글을 써봅니다..
좋은 사이트 항상 감사합니다 저희같은 학생에게는 더없이 좋은 사이트 이네요
|