Updates from tiamtaheri Toggle Comment Threads | Keyboard Shortcuts

  • tiamtaheri 4:20 pm on November 30, 2012 Permalink | Reply  

    [idea] 

    For the Pulse Sensor Project I want to use the values that I get to change the frequency of sound (for example a sine sound)
    I didn’t make a sketch, because this is mostly an audio project.

    The past couple of weeks I was thinking about this project, so this is the idea I want to work on.

     
  • tiamtaheri 6:22 pm on November 16, 2012 Permalink | Reply  

    [assignment_11/16] 

    Here is the case statement code I wrote, unfortunately I get an error, when I try to upload. But all the 4 states work, if I put them in separate sketches:

    int potentiomerPin=0;
    int photocellPin=1;
    int photocellReading;
    int ledPin=10;
    int ledBrightness;
    int speakerPin=12;
    int speakerFrequency;
    int delayPeriod;
    void setup() {
    Serial.begin(9600);
    pinMode(ledPin, OUTPUT);
    }
    void loop(){
    if(Serial.available()) {
    char ch=Serial.read();
    switch(ch);
    }

    case ‘1’:
    number1();
    break;
    case ‘2’:
    number2();
    break;

    case ‘3’:
    number3();
    break;

    case’4′:
    number4();
    break;

    default:
    Serial.print(ch);
    Serial.println(” was received but not expected”);
    break;

    }
    }

    }

    void number1 () {
    int potsensorValue=analogRead(A0);
    photocellReading=analogRead(A1);
    Serial.print(“Potentiometervalue: “);
    Serial.println(potsensorValue);

    Serial.print(“Photocellvalue: “);
    Serial.println(photocellReading);

    delay(1);

    ledBrightness=map(potsensorValue,0,1023,0,255);
    analogWrite(ledPin, ledBrightness);
    speakerFrequency=map(photocellReading, 0,1023,0,255);
    tone(speakerPin,speakerFrequency*10);
    delay(50);
    noTone(speakerPin);
    delay(50);
    }

    void number2 () {
    int potsensorValue=analogRead(A0);
    photocellReading=analogRead(A1);
    Serial.print(“Potentiometervalue: “);
    Serial.println(potsensorValue);

    Serial.print(“Photocellvalue: “);
    Serial.println(photocellReading);

    delay(1);
    photocellReading=1023-photocellReading;
    ledBrightness=map(photocellReading,0,1023,0,255);
    analogWrite(ledPin, ledBrightness);
    speakerFrequency=map(potsensorValue, 0,1023,0,255);
    tone(speakerPin,speakerFrequency*10);
    delay(50);
    noTone(speakerPin);
    delay(50);
    }

    void number3(){
    int potsensorValue=analogRead(A0);
    photocellReading=analogRead(A1);
    Serial.print(“Potentiometervalue: “);
    Serial.println(potsensorValue);

    Serial.print(“Photocellvalue: “);
    Serial.println(photocellReading);

    delay(1);
    delayPeriod=map(photocellReading,0,1023,0,255);

    ledBrightness=map(potsensorValue,0,1023,0,255);
    digitalWrite(ledPin, HIGH);
    delay(ledBrightness);
    digitalWrite(ledPin,LOW);
    delay(ledBrightness);

    speakerFrequency=map(potsensorValue, 0,1023,0,255);
    tone(speakerPin,speakerFrequency*10);
    delay(delayPeriod);
    noTone(speakerPin);
    delay(delayPeriod);

    }

    void number4 () {
    int potsensorValue=analogRead(A0);
    photocellReading=analogRead(A1);
    Serial.print(“Potentiometervalue: “);
    Serial.println(potsensorValue);

    Serial.print(“Photocellvalue: “);
    Serial.println(photocellReading);

    delay(1);
    delayPeriod=map(photocellReading,0,1023,0,255);

    ledBrightness=map(potsensorValue,0,1023,0,255);
    digitalWrite(ledPin, HIGH);
    delay(delayPeriod);
    digitalWrite(ledPin,LOW);
    delay(delayPeriod);

    speakerFrequency=map(potsensorValue, 0,1023,0,255);
    tone(speakerPin,speakerFrequency*10);
    delay(ledBrightness);
    noTone(speakerPin);
    delay(ledBrightness);
    }

     

     
  • tiamtaheri 5:40 pm on October 19, 2012 Permalink | Reply  

    [simon says] 

    //Button Pins

    const int redButt = 11; // declare pins for buttons
    const int yellButt = 10;
    const int blueButt = 9;
    const int greenButt = 8;

    //LED Pins
    const int redLED = 2; // declare pins for LED’s
    const int yellLED = 3;
    const int blueLED = 4;
    const int greenLED = 5;
    // Color Code we Use for R,Y,B,G and 1,2,3,4 repectfully
    const int redValue = 1; // declare values for colors for buttons
    const int yellValue = 2;
    const int blueValue = 3;
    const int greenValue = 4;

    const int speakerPin = 7 ; //declare your speaker pin

    boolean simonDone;
    int simonSays[99] ={
    };
    int nextStep = 0 ;
    int userStep=0;

    int simonSpeed = 300;
    void setup()
    {
    pinMode(redLED, OUTPUT); //Set Pin Mode
    pinMode(yellLED, OUTPUT);
    pinMode(blueLED, OUTPUT);
    pinMode(greenLED, OUTPUT);
    pinMode(speakerPin, OUTPUT); // set speaker to output
    Serial.begin(9600);
    randomSeed(analogRead(0));
    }

    void loop ()
    {
    if (simonDone == false)
    {
    simonSays[nextStep] = random(1,5) ;

    // Serial.print(“nextStep: ” );
    // Serial.println(nextStep);

    // Serial.print(“simonSpeed: ” ); // Show how the new time feature works
    // Serial.println(simonSpeed); // Show how the new time feature works

    // Serial.print(“simonSays: “);

    for (int i =0; i <= nextStep ; i++)
    {
    Serial.print(simonSays[i]);
    Serial.print(” , “);
    delay(simonSpeed); // controls speed that simonSays something

    playToneAndLight(simonSays[i]);

    }

    simonSpeed= (simonSpeed – (nextStep*5)); // This seeds up Simon on each turn by forumla (500-(nextStep*5).
    // Change the multiplier (5 in this case) to make game faster or slower
    // The multiplier is MAJOR factor in how hard the game is.
    // This sets Simon’s TOP SPEED. Also important in making game interesting yet winable.
    simonSpeed = max(simonSpeed, 200); //this maxes out simon speed at 200 ms
    simonDone = true;
    //Serial.println(” “);
    }
    if (simonDone == true)
    {

    if(digitalRead (redButt)==LOW) {
    playToneAndLight (1);
    userCheck(1);
    }

    else if(digitalRead (yellButt)==LOW){
    playToneAndLight (2);
    userCheck(2);
    }

    else if(digitalRead (blueButt) ==LOW) {
    playToneAndLight (3);
    userCheck(3);
    }

    else if( digitalRead(greenButt) == LOW) {
    playToneAndLight(4);
    userCheck(4);
    }

     
    // nothing happening here yet
    // delay(1000);

    // Serial.println(“User got it right, add a new step and give Simon a Turn”);

    // // user completed successfully, give simon the next turn
    // // add one more step to simon’s sequence
    }
    }
    void userCheck (int x) {
    Serial.println(“–starting values–“);
    Serial.print(“value checking against “);
    Serial.print(simonSays[userStep]);
    Serial.print(” “);
    Serial.print(“value user “);
    Serial.println(x);
    Serial.println(” user “);
    Serial.println(userStep);
    Serial.println(” simon “);
    Serial.println(nextStep);
    Serial.println(“—-“);

    if(x==simonSays[userStep]) {

    Serial.println(“User right”);
    if(userStep == nextStep) {
    simonDone = false;
    nextStep++;
    userStep=0;
    }
    else {
    userStep++;
    }
    }
    else {
    tone(7, random(100,3000), 100);
    digitalWrite(2,HIGH);
    digitalWrite(3,HIGH);
    digitalWrite(4,HIGH);
    digitalWrite(5,HIGH);
    delay(100);
    digitalWrite(2,LOW);
    digitalWrite(3,LOW);
    digitalWrite(4,LOW);
    digitalWrite(5,LOW);
    delay(100);
    tone(7, random(100,3000), 100);
    digitalWrite(2,HIGH);
    digitalWrite(3,HIGH);
    digitalWrite(4,HIGH);
    digitalWrite(5,HIGH);
    delay(100);
    digitalWrite(2,LOW);
    digitalWrite(3,LOW);
    digitalWrite(4,LOW);
    digitalWrite(5,LOW);
    delay(100);
    tone(7, random(100,3000), 100);
    digitalWrite(2,HIGH);
    digitalWrite(3,HIGH);
    digitalWrite(4,HIGH);
    digitalWrite(5,HIGH);
    delay(100);
    digitalWrite(2,LOW);
    digitalWrite(3,LOW);
    digitalWrite(4,LOW);
    digitalWrite(5,LOW);
    delay(100);
    nextStep=0;
    userStep=0;
    simonDone = false;
    Serial.println(“Failure”);
    }
    Serial.println(“–outputnext–“);
    Serial.println(userStep);
    Serial.println(nextStep);
    Serial.println(“—-“);
    }

     

     

     
  • tiamtaheri 4:50 am on October 12, 2012 Permalink | Reply  

    sounds 

    Startup:

    Version 1:

    int speakerPin=8;

    void setup(){
    pinMode(8,OUTPUT);

    }
    void loop (){
    for( int y=0; y<3000; y+=2) {
    tone(speakerPin,random(10,y));
    delay(4);

    }

    }

     

    Version 2 (favorite):

    int speakerPin=8;

    void setup(){
    pinMode(8,OUTPUT);

    }
    void loop (){
    for( int y=0; y<3000; y+=2) {
    tone(speakerPin,random(0,y));
    delay(4);

    }

    }

     

    Version 3:

     

    int speakerPin=8;

    void setup(){
    pinMode(8,OUTPUT);

    }
    void loop (){
    for( int y=0; y<3000; y+=2) {
    tone(speakerPin,random(1000,y),6);
    }

    }

     

     

    You are wrong-sounds:

    Version 1:

    1. include “pitches.h”

    int melody [] = {NOTE_A1,NOTE_B0,NOTE_D2};
    int noteDurations [] = {1};

    void setup() {

    }

    void loop() {
    for (int thisNote = 0; thisNote < 3; thisNote++) {
    int noteDuration = 1000/noteDurations[thisNote];
    tone(8, melody[thisNote],noteDuration);
    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);
    noTone(8);
    }

    }

     

    Version 2:

    1. include “pitches.h”

    int melody [] = {NOTE_F1,NOTE_CS5,NOTE_CS8 };
    int noteDurations [] = {1};

    void setup() {

    }

    void loop() {
    for (int thisNote = 0; thisNote < 3; thisNote++) {
    int noteDuration = 1000/noteDurations[thisNote];
    tone(8, melody[thisNote],noteDuration);
    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);
    noTone(8);
    }

    }

     

    Version 3:

    1. include “pitches.h”

    int melody [] = {NOTE_GS7,NOTE_CS7,NOTE_FS4 };
    int noteDurations [] = {1};

    void setup() {

    }

    void loop() {
    for (int thisNote = 0; thisNote < 3; thisNote++) {
    int noteDuration = 1000/noteDurations[thisNote];
    tone(8, melody[thisNote],noteDuration);
    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);
    noTone(8);
    }

    }

     

     

     

     

     

     

     

     

     
  • tiamtaheri 2:08 am on October 12, 2012 Permalink | Reply  

    simon says ideas 

    Here are my 3 enclosure ideas:

    1. for the first one I tried to keep it simple and clean. I tried to have some kind of symmetry, but with the switch and battery-pack it’s going to be tricky

     

    2. the main idea is mimesis: some kind of distorted geometrical form that gets close to the shape of a stone

     

    3. to embrace the nerd-ness: taking random circuits to build an enclosure for simon

     

    I am still working on the code.

     

     

     

     

     

    Inspiration:

     

     
  • tiamtaheri 4:22 pm on October 5, 2012 Permalink | Reply  

    maker faire 

    This slideshow requires JavaScript.

     

    Description comes after class 🙂

     

     

     
  • tiamtaheri 6:10 pm on September 28, 2012 Permalink | Reply  

    test 

    test

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel