6th Assignment (Aduino)

Based on what I learned in CClab and Pcom, I made a fortune teller – arduino by myself.

While I was working on this, I almost gave up but i tried to connect again from the first part.

I am so happy that this project is exactly what I want to do at the first time.

I used 8×8 dot matrix to show emoticon.

there are 3 option (I used random function) led1, led2, and led3.

Once it start I used buttonPin which is pin7. if this button state is high, it generate random number (0 to 2)

this is my code.

vimeo video – fortune teller1

vimeo video – fortune teller2

this is the website that I convert to hexadecimal here

I found this drawing pixel generator website

 

 

 

int randNumber;
int val = 0;
int buttonPin = 7;
//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
//Pin connected to DS of 74HC595
int dataPin = 11;
int count=0;
int led1 = 3;
int led2 = 5;
int led3 = 10;
byte test[8];
byte drawing1[8];
byte drawing2[8];
byte drawing3[8];
void setup(){
pinMode(buttonPin, INPUT);
Serial.begin(9600);
pinMode(led1, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
test[0]=0x7F; //01111111
test[1]=0xBF; //10111111
test[2]=0xDF; //11011111
test[3]=0xEF; //11101111
test[4]=0xF7; //11110111
test[5]=0xFB; //11111011
test[6]=0xFD; //11111101
test[7]=0xFE; //11111110
drawing1[0]=0×66;
drawing1[1]=0xF7;
drawing1[2]=0x7F;
drawing1[3]=0x3E;
drawing1[4]=0x7C;
drawing1[5]=0xFE;
drawing1[6]=0xEF;
drawing1[7]=0×66;
drawing2[0]=0×66;
drawing2[1]=0xF7;
drawing2[2]=0x7F;
drawing2[3]=0x3E;
drawing2[4]=0x7C;
drawing2[5]=0xFE;
drawing2[6]=0xEF;
drawing2[7]=0×66;
drawing3[0]=0×66;
drawing3[1]=0xF7;
drawing3[2]=0x7F;
drawing3[3]=0x3E;
drawing3[4]=0x7C;
drawing3[5]=0xFE;
drawing3[6]=0xEF;
drawing3[7]=0×66;
randomSeed(analogRead(0));
}
void loop() {
Serial.println(randNumber);
val = digitalRead(buttonPin);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
randNumber = random(1000)%3;
if (val == HIGH) {
if (randNumber == 0){
digitalWrite(led1, HIGH);
}
if (randNumber == 1){
digitalWrite(led2, HIGH);
}
if(randNumber == 2){
digitalWrite(led3, HIGH);
}
}
if(val == LOW){
digitalWrite(led1, LOW);
digitalWrite(led1, LOW);
digitalWrite(led1, LOW);
}
Serial.println(randNumber);
}