Mini Apple II-“Surprise” Machine for Halloween
0 733 Medium

 

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.

The function of the program is as shown below:

 

 

 

projectImage

 

1. 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

 

projectImage

 

2. Software

1. Arduino IDE

2. Img2Lcd(Converting Images to Code)

3. Operation

1) Connection Diagram

 

projectImage
projectImage

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

projectImage
projectImage

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

 

 

projectImage

2) Process Images

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

projectImage

Download and install Img2Lcd. Open up and import images into it, set the images as the way shown below, then we will get 7 .c files.

 

projectImage
projectImage

 

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

 

projectImage

4) Revise Code

We have to call the corresponding image at the set distance. The revised codes will be shown below:

 ● Copy the image information to the beginning of the Code,  as shown below:

projectImage

● Main Program

 

CODE
#include "SPI.h"
#include <DFRobot_GDL.h>
#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;
}
}

6) Design and Assembly Enclosure

Apple II Model diagram:

projectImage

Laser Cutting Diagram (Unit: mm)

 

projectImage
icon Laser Cutting Diagram.rar 16KB Download(1)
projectImage
projectImage
projectImage

7) Burn Code and Display effect

projectImage

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.

 

 

icon Image2Lcd 2.9(破解版).zip 512KB Download(0)
License
All Rights
Reserved
licensBg
0