topical media & game development

talk show tell print

graphic-processing-algorithm-Ch11-p293-p293.pde / pde



  // do re mi fa sol la si do
  int freqs[] = { 
    1915, 1700, 1519, 1432, 1275, 1136, 1014, 956};
  void setup(){
    pinMode(11,OUTPUT);
    Serial.begin(9600);
  }
  void loop(){
    int value = analogRead(0);
    int tone = (value/100)%8;
    Serial.println(tone);
    for(int i=0; i<100; i++){
      digitalWrite(11,HIGH);
      delayMicroseconds(freqs[tone]);
      digitalWrite(11,LOW);
      delayMicroseconds(freqs[tone]);
    }
  }
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.