Project: Physical Computing

Arduino – Plum Piano using MPR121

  code: #include <MPR121.h> #include <MPR121_defs.h> #include <Wire.h> // Wiring two-wire library for I2C #include “mpr121.h” // register definitions int notes[]={239,213,190,179,159,142}; char touch_previous; void setup() { Serial.begin(9600); pinMode(9,OUTPUT); pinMode(10,OUTPUT); TCCR2A = _BV(COM2A0) | _BV(COM2B1) | _BV(WGM20); TCCR2B = _BV(WGM22) | _BV(CS22); OCR2B = 10; // MPR121 CONFIG Wire.begin(); mpr121QuickConfig(); touch_previous=0; } void loop() { char buffer[32]; int i=0; int note=0; Wire.beginTransmission(0x5A); Wire.write(0); Wire.requestFrom(0x5A, 18); while(Wire.available()) { buffer[i] = Wire.read(); i++; } Wire.endTransmission(); if (buffer[0] !=… More

Arduino Basic – Blink

bgm: birthday – Katy Perry code: int lled =11; int rled =9; void setup() { pinMode(lled, OUTPUT); pinMode(rled, OUTPUT); } void loop() { digitalWrite(rled, HIGH); delay(370); digitalWrite(rled, LOW); digitalWrite(lled, HIGH); delay(100); digitalWrite(lled, LOW); digitalWrite(rled, HIGH); delay(100); digitalWrite(rled, LOW); digitalWrite(lled, HIGH); delay(370); digitalWrite(lled, LOW); }… More