Mini Apple II-“Surprise” Machine for Halloween

by Jaychouu in Circuits > Electronics

1053 Views, 2 Favorites, 0 Comments

Mini Apple II-“Surprise” Machine for Halloween

成品图.jpg
成品2.jpg
IMG_20201029_161944.jpg

I always get startled easily. I had tried to stop feeling scared by little things all the time. But, well, it’s so hard to change one’s nature, so at last, I decided to take it. One day, at the office, I was working in front of my computer with all my attention focused on the screen, a voice from nowhere suddenly drummed in my ears, and gave me a great fright. It turned out to be my colleague, he didn’t mean to spook me, but I don’t want this happening again. So I need a device to prompt me that somebody is coming to me when I am immersed in my work so I will not get frightened. Besides that, Halloween is coming, I am gonna make something fun. I have a rough idea in mind. Generally, it goes like this: first use some intriguing images to attract people to come closer, when the person is in a certain range, the device enters scary mode with frightening pictures appearing abruptly. If someone wants to give me some “surprises” on Halloween, then I will be using this device to treat him.

As for the appearance of the device, I want to make it like an Apple II. Some of you may have heard of this computer, it is launched in 1977, regarded as one of the most successful personal computers. The case of Apple II was designed to look more like a home appliance than a piece of electronic equipment. I fell in love with this computer the first time I met it in my History of Design class. And it is always on my dream product list. Now I think it is a great opportunity. So basically this is where the idea of my mini Apple II “surprise” machine comes from.

Supplies

  • Hardware List

1. Firebeetle Board-M0 (V1.0) X1
2. 2.8” 320x240 IPS TFT LCD Touchscreen with MicroSD

3. Gravity: URM09 Analog Ultrasonic Sensor

4. Four Feet Button Switch

5. 220Ω Resistor

6. Dupont Wires

7. Gravity 3P Wire

8. GDI Wire-30cm

9. Type-c Cable

  • Software

1. Arduino IDE

2. Image2LCD

Connection Diagram

连线图.png
IMG_20201029_230417.jpg
IMG_20201029_230115.jpg
B3_RXG0}S%$SJRU6HYWYHO3.png
VT3[`@5D$]T9J68W4]@2[ZT.png

Solder Pin header to M0 board. Here we need an analog pin and a digital pin(P3 is digital, for connecting with the button; A3 is analog, for connecting to the ranging sensor ).

Add a 220Ω resistor when soldering GND wire to the button switch.

Process Images

]QSP%2NF36OF{RYE@$Z21O5.png
}538}@O46}C(MJ[05HW$$~U.png
4PCS]KZA)]B3F2SPVJRCC]I.png

Download 7 suitable images from internet, cut and rotate 4:3, and name them as 1 to7.

Download and install Img2Lcd. Open up and import images into it, set the size of images 1 and 7 to 120*160, set 2 to 6 to 60*80, then we will get 7 .c files.

Download GDL Screen Library File.

Wiki.png

Download GDL screen library file. Unzip the file and copy it into Arduino Library.

Program Flowchart

思路图.jpg

The function of the program is as Shown Above.

Revise Code

HD0G_U5V{JCJT37%O_IHE$F.png
#include "SPI.h" #include #include "DFRobot_GDL.h" #define screen_CS 5 #define screen_DC 7 #define screen_LED 0 #define screen_RST 6 //DFRobot_ST7789_240x240_HW_SPI screen(/*dc=*/screen_DC,/*cs=*/screen_CS,/*rst=*/screen_RST); //DFRobot_ST7789_240x320_HW_SPI screen(/*dc=*/screen_DC,/*cs=*/screen_CS,/*rst=*/screen_RST); //DFRobot_ILI9341_240x320_HW_SPI screen(/*dc=*/screen_DC,/*cs=*/screen_CS,/*rst=*/screen_RST); //DFRobot_ILI9488_320x480_HW_SPI screen(/*dc=*/screen_DC,/*cs=*/screen_CS,/*rst=*/screen_RST); /* M0 mainboard DMA transfer */ //DFRobot_ST7789_240x240_DMA_SPI screen(/*dc=*/screen_DC,/*cs=*/screen_CS,/*rst=*/screen_RST); //DFRobot_ST7789_240x320_DMA_SPI screen(/*dc=*/screen_DC,/*cs=*/screen_CS,/*rst=*/screen_RST); DFRobot_ILI9341_240x320_DMA_SPI screen(/*dc=*/screen_DC,/*cs=*/screen_CS,/*rst=*/screen_RST); //DFRobot_ILI9488_320x480_DMA_SPI screen(/*dc=*/screen_DC,/*cs=*/screen_CS,/*rst=*/screen_RST); long time3; int sensorPin=A3; int buttonPin=3; int sensorValue=0; int buttonState; int lastButtonState = LOW; int n=0; const unsigned char *c[7]={ gImage_1, gImage_2, gImage_3, gImage_4, gImage_5, gImage_6, gImage_7 }; void setup() { // put your setup code here, to run once: pinMode(buttonPin,INPUT); Serial.begin(9600); screen.begin(); time3 = millis(); Serial.println(millis()-time3); } void loop() { // put your main code here, to run repeatedly: sensorValue = analogRead(sensorPin); Serial.println(sensorValue); int reading = digitalRead(buttonPin); if(sensorValue>300){ if(n>0){ for(int i=n;i>0;i--){ screen.zoomPicture((void*)c[i],2); delay(100); } } else{ screen.zoomPicture((void*)c[n],2); delay(100); } n=0; } else if(sensorValue>250){ if(n>1){ for(int i=n;i>1;i--){ screen.zoomPicture((void*)c[i],2); delay(100); } } else if(n<1){ for(int i=n;i<1;i++){ screen.zoomPicture((void*)c[i],2); delay(100); } } else{ screen.zoomPicture((void*)c[n],2); delay(100); } n=1; } else if(sensorValue>200){ if(n>2){ for(int i=n;i>2;i--){ screen.zoomPicture((void*)c[i],2); delay(100); } } else if(n<2){ for(int i=n;i<2;i++){ screen.zoomPicture((void*)c[i],2); delay(100); } } else{ screen.zoomPicture((void*)c[n],2); delay(100); } n=2; } else if(sensorValue>150){ if(n>3){ for(int i=n;i>3;i--){ screen.zoomPicture((void*)c[i],2); delay(100); } } else if(n<3){ for(int i=n;i<3;i++){ screen.zoomPicture((void*)c[i],2); delay(100); } } else{ screen.zoomPicture((void*)c[n],2); delay(100); } n=3; } else if(sensorValue>100){ if(n>4){ for(int i=n;i>4;i--){ screen.zoomPicture((void*)c[i],2); delay(100); } } else if(n<4){ for(int i=n;i<4;i++){ screen.zoomPicture((void*)c[i],2); delay(100); } } else{ screen.zoomPicture((void*)c[n],2); delay(100); } n=4; } else if(sensorValue>50){ if(n>5){ for(int i=n;i>5;i--){ screen.zoomPicture((void*)c[i],2); delay(100); } } else if(n<5){ for(int i=n;i<5;i++){ screen.zoomPicture((void*)c[i],2); delay(100); } } else{ screen.zoomPicture((void*)c[n],2); delay(100); } n=5; } else{ buttonState = reading; if (buttonState == HIGH){ if(n<6){ for(int i=n;i<6;i++){ screen.zoomPicture((void*)c[i],2); delay(100); } } else{ screen.zoomPicture((void*)c[n],2); delay(100); } n=6;} else{ if(n<6){ for(int i=n;i<=5;i++){ screen.zoomPicture((void*)c[i],2); delay(100); } } n=5; } lastButtonState= buttonState; } }

Design and Assembly Enclosure

QQ图片20201030145407.png
B_TQ_R5DXQ9N{$E]}@7NSOE.png
IMG_20201029_164337-02.jpeg
IMG_20201029_165120-01.jpeg
成品3&lsquo;.jpg

Apple II Model diagram:

Laser Cutting Diagram (Unit: mm)

Burn Code and Display Effect

串口数据.gif
Apple II Surprise Machine

Okay, that’s all for my Surprise Machine, the related files are attached here. Welcome to share your opinion about this project, or DIY your own APPLE II Machine.