B.F.F. - HKU - ITTT

Introduction: B.F.F. - HKU - ITTT

About: Nadja May Kramer

HKU ITTT school assignment.

I made a character inspired by a Tamagotchi, it can just be happy but it can also sleep and get angry. Just like your normal average friend. Follow these instructions to make your own friend! Designed to help people who are lonely.

Supplies:

  • 3mm MDF wood for lasercutting
  • Arduino UNO
  • Wires
  • Breadboard
  • Matrix 8x8 led (x2)
  • Small button
  • Pressure sensor
  • Tilt sensor

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Wiring and Soldering

Make sure you connect all the right wires, I used red for volt (+) and black for GND (-). I soldered the button wires, I added 2 wires to 2 outputs and connected them through the breadboard. Also make sure that you connected the right wire combination between the 2 Matrix led screens, if you dont connect it right it wont work at all.

Step 2: Coding Arduino

I added the code as a file but below is also the code for you to copy! The code makes the character idle on the Martix led with writeBlink(); if the pressure sensor is touched it will play writeExcite(); and if you tilt the character to a sleeping position it wil use writeSleep(); so it will sleep. When the button is pressed a light on the inside will light up.

#include

LedControl lc=LedControl(12,11,10,2);

int ledPin = 13;

int sensorPin = 4;

int sensorPin2 = 2;

int sensorPin3 = A0;

int sensorValue;

int lastTiltState = HIGH;

long lastDebounceTime = 0;

long debounceDelay = 50;

unsigned long delaytime = 500;

void setup() {

lc.shutdown(0,false);

lc.setIntensity(0,8);

lc.clearDisplay(0);

lc.shutdown(1,false);

lc.setIntensity(1,8);

lc.clearDisplay(1);

pinMode(ledPin, OUTPUT);

pinMode(sensorPin, INPUT);

pinMode(sensorPin2, INPUT);

pinMode(sensorPin3, INPUT);

digitalWrite(sensorPin, HIGH);

digitalWrite(sensorPin2, HIGH);

digitalWrite(sensorPin3, HIGH);

Serial.begin(9600);

}

void writeBlink() {

byte owo[8]={B00011111,B00010001,B01011111,B10000000,B10000000,B01011111,B00010001,B00011111}; byte owo2[8]={B00011110,B00010010,B01011110,B10000000,B10000000,B01011110,B00010010,B00011110}; byte owo3[8]={B00011100,B00010100,B01011100,B10000000,B10000000,B01011100,B00010100,B00011100}; byte owo4[8]={B00011000,B00011000,B01011000,B10000000,B10000000,B01011000,B00011000,B00011000}; byte one[8]={B00000000,B00000110,B00001110,B00011100,B00001110,B00000110,B00000000,B00000000}; byte two[8]={B00000000,B00000000,B00001100,B00011100,B00111000,B00011100,B00001100,B00000000}; byte three[8]={B00000000,B00011000,B00111000,B01110000,B00111000,B00011000,B00000000,B00000000};

//1

lc.setRow(0,0,owo[0]); lc.setRow(0,1,owo[1]); lc.setRow(0,2,owo[2]); lc.setRow(0,3,owo[3]); lc.setRow(0,4,owo[4]); lc.setRow(0,5,owo[5]); lc.setRow(0,6,owo[6]); lc.setRow(0,7,owo[7]);

//2

lc.setRow(1,0,one[0]); lc.setRow(1,1,one[1]); lc.setRow(1,2,one[2]); lc.setRow(1,3,one[3]); lc.setRow(1,4,one[4]); lc.setRow(1,5,one[5]); lc.setRow(1,6,one[6]); lc.setRow(1,7,one[7]);

delay(delaytime);

//1

lc.setRow(0,0,owo2[0]); lc.setRow(0,1,owo2[1]); lc.setRow(0,2,owo2[2]); lc.setRow(0,3,owo2[3]); lc.setRow(0,4,owo2[4]); lc.setRow(0,5,owo2[5]); lc.setRow(0,6,owo2[6]); lc.setRow(0,7,owo2[7]);

//2

lc.setRow(1,0,two[0]); lc.setRow(1,1,two[1]); lc.setRow(1,2,two[2]); lc.setRow(1,3,two[3]); lc.setRow(1,4,two[4]); lc.setRow(1,5,two[5]); lc.setRow(1,6,two[6]); lc.setRow(1,7,two[7]);

delay(delaytime);

//1

lc.setRow(0,0,owo3[0]); lc.setRow(0,1,owo3[1]); lc.setRow(0,2,owo3[2]); lc.setRow(0,3,owo3[3]); lc.setRow(0,4,owo3[4]); lc.setRow(0,5,owo3[5]); lc.setRow(0,6,owo3[6]); lc.setRow(0,7,owo3[7]); delay(delaytime);

//1

lc.setRow(0,0,owo4[0]); lc.setRow(0,1,owo4[1]); lc.setRow(0,2,owo4[2]); lc.setRow(0,3,owo4[3]); lc.setRow(0,4,owo4[4]); lc.setRow(0,5,owo4[5]); lc.setRow(0,6,owo4[6]); lc.setRow(0,7,owo4[7]);

//2

lc.setRow(1,0,three[0]); lc.setRow(1,1,three[1]); lc.setRow(1,2,three[2]); lc.setRow(1,3,three[3]); lc.setRow(1,4,three[4]); lc.setRow(1,5,three[5]); lc.setRow(1,6,three[6]); lc.setRow(1,7,three[7]); delay(delaytime);

//1

lc.setRow(0,0,owo3[0]); lc.setRow(0,1,owo3[1]); lc.setRow(0,2,owo3[2]); lc.setRow(0,3,owo3[3]); lc.setRow(0,4,owo3[4]); lc.setRow(0,5,owo3[5]); lc.setRow(0,6,owo3[6]); lc.setRow(0,7,owo3[7]);

//2

lc.setRow(1,0,two[0]); lc.setRow(1,1,two[1]); lc.setRow(1,2,two[2]); lc.setRow(1,3,two[3]); lc.setRow(1,4,two[4]); lc.setRow(1,5,two[5]); lc.setRow(1,6,two[6]); lc.setRow(1,7,two[7]);

delay(200);

//1

lc.setRow(0,0,owo[0]); lc.setRow(0,1,owo[1]); lc.setRow(0,2,owo[2]); lc.setRow(0,3,owo[3]); lc.setRow(0,4,owo[4]); lc.setRow(0,5,owo[5]); lc.setRow(0,6,owo[6]); lc.setRow(0,7,owo[7]);

delay(200);

//2

lc.setRow(1,0,three[0]); lc.setRow(1,1,three[1]); lc.setRow(1,2,three[2]); lc.setRow(1,3,three[3]); lc.setRow(1,4,three[4]); lc.setRow(1,5,three[5]); lc.setRow(1,6,three[6]); lc.setRow(1,7,three[7]);

delay(200);

}

void writeExcite() {

byte wow[8]={B00001010, B00000100, B00101010, B00100000, B00100000, B00101010, B00000100, B00001010};

byte anger[8]={B00000000, B00000000, B00101000, B01101100, B00000000, B01101100, B00101000, B00000000};

byte anger2[8]={B00000000, B01000100, B11000110, B00000000, B00000000, B00000000, B11000110, B01000100};

byte anger3[8]={B00000000, B00000000, B00010000, B00111000, B00010000, B00000000, B00000000, B00000000};

//1 lc.setRow(0,0,wow[0]); lc.setRow(0,1,wow[1]); lc.setRow(0,2,wow[2]); lc.setRow(0,3,wow[3]); lc.setRow(0,4,wow[4]); lc.setRow(0,5,wow[5]); lc.setRow(0,6,wow[6]); lc.setRow(0,7,wow[7]);

//2 lc.setRow(1,0,anger[0]); lc.setRow(1,1,anger[1]); lc.setRow(1,2,anger[2]); lc.setRow(1,3,anger[3]); lc.setRow(1,4,anger[4]); lc.setRow(1,5,anger[5]); lc.setRow(1,6,anger[6]); lc.setRow(1,7,anger[7]); delay(600);

//2 lc.setRow(1,0,anger3[0]); lc.setRow(1,1,anger3[1]); lc.setRow(1,2,anger3[2]); lc.setRow(1,3,anger3[3]); lc.setRow(1,4,anger3[4]); lc.setRow(1,5,anger3[5]); lc.setRow(1,6,anger3[6]); lc.setRow(1,7,anger3[7]); delay(300);

//2 lc.setRow(1,0,anger[0]); lc.setRow(1,1,anger[1]); lc.setRow(1,2,anger[2]); lc.setRow(1,3,anger[3]); lc.setRow(1,4,anger[4]); lc.setRow(1,5,anger[5]); lc.setRow(1,6,anger[6]); lc.setRow(1,7,anger[7]); delay(600);

//2 lc.setRow(1,0,anger3[0]); lc.setRow(1,1,anger3[1]); lc.setRow(1,2,anger3[2]); lc.setRow(1,3,anger3[3]); lc.setRow(1,4,anger3[4]); lc.setRow(1,5,anger3[5]); lc.setRow(1,6,anger3[6]); lc.setRow(1,7,anger3[7]);

delay(300);

}

void writeSleep() {

byte ztxt[8]={B00000000, B00000000, B00000000, B01001000, B01101000, B01011000, B01001000, B00000000};

byte ztxt1[8]={B00000000, B00010010, B00011010, B00010110, B00010010, B00000000, B00000000, B00000000};

byte zzz[8]={B00011000,B00011000,B01011000,B10000000,B10000000,B01011000,B00011000,B00011000};

//1 lc.setRow(0,0,zzz[0]); lc.setRow(0,1,zzz[1]); lc.setRow(0,2,zzz[2]); lc.setRow(0,3,zzz[3]); lc.setRow(0,4,zzz[4]); lc.setRow(0,5,zzz[5]); lc.setRow(0,6,zzz[6]); lc.setRow(0,7,zzz[7]);

//2 lc.setRow(1,0,ztxt[0]); lc.setRow(1,1,ztxt[1]); lc.setRow(1,2,ztxt[2]); lc.setRow(1,3,ztxt[3]); lc.setRow(1,4,ztxt[4]); lc.setRow(1,5,ztxt[5]); lc.setRow(1,6,ztxt[6]); lc.setRow(1,7,ztxt[7]);

delay(400);

//2 lc.setRow(1,0,ztxt1[0]); lc.setRow(1,1,ztxt1[1]); lc.setRow(1,2,ztxt1[2]); lc.setRow(1,3,ztxt1[3]); lc.setRow(1,4,ztxt1[4]); lc.setRow(1,5,ztxt1[5]); lc.setRow(1,6,ztxt1[6]); lc.setRow(1,7,ztxt1[7]);

delay(400);

}

void loop() {

writeBlink();

int buttonState = digitalRead(sensorPin2);

if (buttonState == HIGH) {

digitalWrite(ledPin, buttonState);

delay(1000);

}

int buttonState2 = analogRead(sensorPin3);

if (buttonState2 > 100) {

writeExcite();

delay(1000);

}

sensorValue = digitalRead(sensorPin);

if (sensorValue == lastTiltState) {

lastDebounceTime = millis();

}

if ((millis() - lastDebounceTime) > debounceDelay) {

lastTiltState = sensorValue;

} digitalWrite(ledPin, lastTiltState);

while (lastTiltState == HIGH) {

writeSleep();

sensorValue = digitalRead(sensorPin);

if (sensorValue == lastTiltState) {

lastDebounceTime = millis();

}

if ((millis() - lastDebounceTime) > debounceDelay) {

lastTiltState = sensorValue;

}

if (lastTiltState == LOW) {

digitalWrite(ledPin, lastTiltState); break;

}

}

}

Step 3: Making the Box

I made a box with lasercutting, it was very interesting to learn.

I used makerCase for the building of my box, I will upload the file below. In the program of the lasercutting tool I added 2 windows on top, one bigger one on front and a long one in the back. You can find the measurements on the images on top.

Attachments

Step 4: Fitting Everything in and Assembling the Box

On the pictures you can see how I fitted everything in the box, make sure the Matrix leds are inserted with the longer part on the bottom. You can use special tape to attach the arduino to the side. Make sure it doesnt move anymore when you move the box and make sure the pressure sensor is poking out of the back as a tail.

Step 5: Testing and Enjoy!

You can test it by attaching a power supply to the arduino.

If its on its back it should start sleeping, if the tail is pressed it should get angry/ have pain, when you press the button on the inside it will light up inside and normally it will just blink in a idle state.

Be the First to Share

    Recommendations

    • LED Strip Speed Challenge

      LED Strip Speed Challenge
    • Sculpting Challenge

      Sculpting Challenge
    • Tiny Speed Challenge

      Tiny Speed Challenge

    Discussions