Skip to content

A Road to My Final Project

This is where I will start defining my final project idea and start to get use to the documentation process.

Week 1 [Idea]

Idea 1: Convenient Stage light with easy control (Easy to carry and ok for small space)

This is a “Lights for the performance”. I do plays as a hobby. Our acting group usually perform at the room in the community center, and it doesn’t have stage facilities. We don’t have enough budget for preparing expensive equipments such as lights and sounds. We want to have the light which is easy to control(as we are not professional), not so expensive to get and repair. It is also easy to carry.

Idea 2: Automatic petting tool

I have a beautiful and cute dog named “Momo”. She is adorable and I really enjoy spending with her. She “often” asks me to pet her. That’s so cute, but… She keeps asking me to do it a bit too much… That means at least one of my hands always occupied with her. So I “need” to have another hand.

What I choose:
I decided to choose first idea, because our performace group alway has a headache about the “light”.

Week 2[Organizing the idea]

Organize the Final project idea

For deciding color..

I got wonderful design image from my instructor.
MIDI Melody Maker
I made rough modeling of Light controler.

Make controler image in 3D

Week 9[Analog input]

As I tested analog input using sliders this week, I could get the image for the changing color with analog input.
Hero Shot

Week 10[Device]

Week 10, we studied about output device. I’m thinking that selecting light color is decided by touching coordinate on the screen where the color chart is on. So I checked the basic movement and touch of the ILI9341 with Raspberry Pi Pico. Though I couldn’t check the jpg display on the screen and SD card, I think ILI9341 seems good as controling and deciding the color panel.

Week 12/Mid Term

When I started to work final project in earnest, I organize my idea about the final project. I began to make the concrete task and list them as I began to concrete my final project.

Concept:

Schedule:

Schedule Made schedule at April 29th.

System Diagram:

  • Controller
    (1) Overall Diagram
  • Controller
graph TD
A([Start]) --> B
B(Main Menu) --> C
C{Setting / Exec / Live } -- Setting --> D(Select Menu)
C{Setting / Exec / Live } -- Exec --> E(Execute Menu)
C{Setting / Exec / Live } -- Live --> F(Live Menu)
D(Select Menu) -- Select Button(1-4) --> G(Make Color by slider)
E(Execute Menu) -- Select Button(1-4) --> H(Send the color into the Light)
F(Live Menu) -- Slide potentiometer --> I(Change color by slider)
G(Make Color by slider) -- Select same button --> J(Memorize the color)
I(Change color by slider) -- Send Color data to the Light -->K(Change the light color)
J(Memorize the color) --> L(Main Menu)
H(Send the color into the Light) --> L(Main Menu)
K(Change the light color) --> L(Main Menu)
  • Light
    graph TD
    A(Wait Data from Contoller) --> B
    B(Receive Data)

What Will I make?

2 spot Lights and Controller

Production

  • Lights :

    • Spotlights
  • Controller :

    • Decide the color
    • Adjust the color
    • Memorize the colors
    • Color lightness/darkness adjustment
    • Adjust the color lively
  • Transmission -> WIFI or cable?

  • network method -> DMX or I2C?

Specification

  • Lights

    • Power LED or Neo Pixel
    • Xiao
  • Controller

    • Touch screen : ILI9341
    • Slider Type Potentiometer :
    • Button for ON/OFF :
    • Button for memory :

material / components

  • Lights:

    • Neo pixel or Power LED
    • How many lights to be needed?
    • I2C or DMX
  • Controller:

    • Slider * 4 (for RGBW)
    • screen (for color, error display, recalling the memory)
    • button (for memory, switch for blackout and manual mode)
    • microcontroller Raspberry Pi Pico 2w(controller), Xiao(light?)

Week 14

I made 2 Arduino codes for light changing. It was for serial communication with Processing, but these codes are possibly used for light controller. Codes are at week14’s document.

First Cardboard prototype

I made controller box 3D image in Fusion360.

Then I made first controller board by cardboard.

As I could see real “object”, I found several points and bad(better to change)points from it.

After making it, thought a bit not showing screw version and made prototype “slide potentiometer cover”. Though nat positions was not quite right and it was a bit difficult to attach them, basic feature fit well and it was good experiment.

ILI9341 Display color check

I also touched ILI9341 for checking the colors that ILI9341_library.h provides.

Code

Check the slider with Raspberry Pi Pico 2w

I tested the slider potentiometer(with analog pin) by using example code “Bar Graph”(Using 3 LEDs for the test though). It was checked if enough analog ports are free for slide potentiometers and it has.

Check the button move

Pushing button was also checked with Pi Pico 2w. I made a simple code by Arduino and check how it worked.

Raspberry Pi Pico Function

Name function Possibly port
ILI9341 GND, 3V3(OUT)x2, GPIO28, GPIO22, GPIO20, GPIO19x2, GPIO18x2,GPIO17, GPIO16
Display
Get Color Data
Display Color
Select button select
Set signal
Slider Change the color(analog)
Big Button(1) Black out
Big Button(2) Enable slider

3D

I made some parts by 3D printings(additive manufacturing).

Week15

This is system integration page(week15) here.

Material List

Block Name Size Required Number Cost Vender Note
Controller Raspberry Pi Pico 2W 21 x 51 (mm) 1 ¥1,710 Akizuki Denshi
ILI9341 50 x 86 (mm) 1 ¥1,450 Akizuki Denshi
Slide Potentiometer 90 x 20 (mm) 2 Fablab Inventory
Slide Potentiometer 90 x 20 (mm) 1 ¥367.8 Amazon
Momentary Switch(Panel mount) 4 Fablab Inventory
button 2 Fablab Inventory
MDF 600 x 300 x 6 1 ¥500 Fablab Inventory
Base Spray for painting 1 ¥1,075 Home center
Light Xiao 1 Fablab Inventory
Neopixel 20 1 Fablab Inventory

Week17

All the woods are cut this week.
First I cut 15mm wood by CNC.
Beforehand, I cut the wood(300*600) to the proper size for CNC.

When using a circular saw, blade should be just a side of the line.

Move it forward not too slow and never pull it back.

The wood was put to the machine(Lead CNC Machine by Openbuilds) and opened it’s software(Openbuilds). This machine was a first time to use but it seemed it didn’t have big difference between Shopbot.

First wood was made holes at 4corners to stop moving.

After that, I put a brush around the endmill and

I set the X, Y axis.

Then set the Z axis. It is good to use a piece of paper between the endmill and the board and shake it until a paper doesn’t move, when checking the Z position.

When push the button, then machine started to cut the board.

Week18

Coding

I wrote the coding by Arduino IDE helped by Instructors and chatGPT. My codes are color selecting part(at controller) and light part(receive data and make the light grow in a specified color).

I started coding with simple menu display for ILI9341. First menu has select menu and go to each menu with touching certain area(with white rectangle). Main menu has 2 selecting items(later add Live menu),”Setting Menu” and “Exec Menu”.

Then, I made the setting menu display and operation code.

Add hinge

At first I searched for hinges on the internet and found them. However, it was too large and found and put proper sized one at the Kamakura inventory.

PCB

I designed and miiled the pcb board for connecting Raspberry Pi Pico and other devices.

I designed it by Ki-Cad and make PCB board design too. Then take from PCB design export to svg file and pico2w-B_Cu.svg and pico2w-F_Cu.svg are came out.
Then, mods program is opened and select “program” -> “open program” -> “SRM-20 mill mill 2DPCB” with right click.
Then 3 files(path, hole, and outline files) are made and put them into SRM.

I milled it with SRM. Path milling(1/64 endmill) was totally fine but the cut with 1/32 wasn’t work properly(maybe too short?) it didn’t cut through.

I tried second one. Second one seemed OK but there are 2 parts which”should be holes”.

I milled it third time and it worked well this time. Now it’s time for soldering.

Try and Error

When I began to solder pins, I found this was too difficult to do it.

I tried to solder those pins many ways but it didn’t work. It was also peeled off some of the copper. It was failed.

I remake the PCB board again but this time, I made it with the front and back reversed. Then I can solder the shorter pin easily.

Till the End of 1st spiral

Coding

I created the code with help from ChatGPT. The basic idea and most of the coding were done by me, but I got assistance with Wi-Fi communication, debugging, and some parts of the color exchange process. I also tried to write functions for operations that are performed repeatedly in various parts of the code, so they can be called whenever needed.

  • Library

These are libraries used for display and networking. As ILI9341 has touch screen function, there is an library for touch too.

  • Adafruit_ILI9341.h : Library for ILI9341
  • Adafruit_GFX.h : it is for Display function(position, drawing…)
  • XPT2046_Touchscreen.h : Touch panel library

These libraries are for the network.

  • SPI.h
  • WiFi.h
  • WebServer.h

  • Setting

It has 2 setup() functions(setup() and setup1()). Setup() is usual setting up function and setup1() is for wifi setting. First setup() is executed to set SPI transaction, Wifi network, serial transaction and Tft setting. It is also set button’s setting. Setup1() is executed in it too.

  • Display

Display code has “current display” variable for showing proper menu on the screen. First it is put the Main menu value, and select Main menu by switch sentence.

  • Main Menu


At Main Menu, you can choose further functions by touching the screen;

  • Setting : Set the color and memorize
  • Execute : Send the color data memorized at “Setting” to the light
  • Live : Make colors and send it’s data to the light instantly

When touching the screen, check the area where is inside the menu or not. Then if touching area is inside the menu, move to next function.

  int current_disp = 0;

  switch(current_disp){
    case MAIN_MENU:     // Main Menu
        if (!screenDrawn) {
            Main_Menu();
            screenDrawn = true;
        } 
            // Calibration
            Calib_pos(pos_x, pos_y);
            if(pos_x != -1 && pos_y != -1){
                if (isTouchInsideRect(pos_x, pos_y, start1_x, start1_y, end1_x, end1_y)) {
                    current_disp = SET_MENU;
                    screenDrawn = false;
                } else if (isTouchInsideRect(pos_x, pos_y, start2_x, start2_y, end2_x, end2_y)) {
                    current_disp = EXEC_MENU;
                    screenDrawn = false;
                } else if(isTouchInsideRect(pos_x, pos_y, start3_x, start3_y, end3_x, end3_y)){
                    current_disp = LIVE_MENU;

                } else {
                    Err_msg("Please SELECT 1,2 or 3");
                }
                while(ts.touched()) delay(10);
            }
        break;
    case SET_MENU:
        Set_Menu();
        current_disp = MAIN_MENU;
        screenDrawn = false;
        break;
    case EXEC_MENU:
        Exec_Menu();
        current_disp = MAIN_MENU;
        screenDrawn = false;
        break;
    case LIVE_MENU:
        Live_Menu();
        current_disp = MAIN_MENU;
        screenDrawn = false;
        break;
    default:
        Err_msg("Please SELECT 1 or 2");
        screenDrawn = false;
  }
  • Setting Menu


First select and push one of the button at the upper left side. Then selecting color by slide potentiometer. The value of slide potentiometer is not from 0 to 255, so it is needed to have value exchange function.
Basically, I made these functions but chatGPT debugged them and modify the data type in Read_slide_data().

/********************
    Col_palette()
 ********************/
void Col_palette(){

    float h = 0;
    float s = 0;
    float v = 0;

    long RGB = 0;

    if(color_mode == COL_RGB){
      // RGB
      r = Read_slide_data(SL1, slide_min_val, slide_max_val, rgb_min_val, rgb_max_val);
      g = Read_slide_data(SL2, slide_min_val, slide_max_val, rgb_min_val, rgb_max_val);
      b = Read_slide_data(SL3, slide_min_val, slide_max_val, rgb_min_val, rgb_max_val);

    }else if(color_mode == COL_HSV){
      h = Read_slide_data(SL1, slide_min_val, slide_max_val, h_min_val, h_max_val);
      s = Read_slide_data(SL2, slide_min_val, slide_max_val, s_min_val, s_max_val);
      v = Read_slide_data(SL3, slide_min_val, slide_max_val, v_min_val, v_max_val);

      // Change data to RGB
//  hsv2Rgb(h, s, v, r, g, b);
    }

    // Check if value is more than 255 put 255 and if value is less than 0 put 0
    r = constrain(r, 0, 255);
    g = constrain(g, 0, 255);
    b = constrain(b, 0, 255);

    // Color data change to HEX 
//    RGB = rgb_hex(r, g, b);
      Col_Rect();
}
/********************
    Read_slide_data()
 ********************/
float Read_slide_data(int port, int from_min, int from_max, int to_min, int to_max){
    float val;
    float retval;

    // Get the data
    val = analogRead(port);
    // for debug
    //tft.printf("val:%d  ",val);
//    return map(val, from_min, from_max, to_min, to_max);

    retval = mapFloat(val, from_min, from_max, to_min, to_max);
    return retval;
}

Then push the same button again when you finish making the color. This means the color information is memorized in buffer connecting with the button no.

  • Exec Menu


When you touch the “Exec Menu”, choose the button for sending color data to the light. When it is selected, the color you made at the setting shows and ask if it is ok to send it to the light. Touch “Yes” rectangle, the data sends to the light and the color the light. If you touch “No” and touch the screen again, display is back to Main Menu.

  • Live Menu


Live menu is making the color at the controller and send it’s color data to the light and change the color instantly. This function works until touching the screen.

void Live_Menu() {

    // Main loop
    // Previous value for change detection
    int prev_r = -1, prev_g = -1, prev_b = -1;

    while (!ts.touched()) {
        // Update value
        Col_palette();

        // Check for changes
        if (r != prev_r || g != prev_g || b != prev_b) {
            Send_data_to_led(); // 送信
            prev_r = r;
            prev_g = g;
            prev_b = b;
        }
    }
    // This part is from chatGPT
    // Wait until touch is released (Debounce)
    while (ts.touched()) {
        delay(10);
    }
}
  • Prepare for sending color data

The data is made before sending data. This part is made by chatGPT by asking as “I want to send RGB data to the client and turn on the light in the color you specify”. Then I got this code for sending data.

void handleRGB() {
  StaticJsonDocument<200> doc;
  doc["r"] = (int)r;
  doc["g"] = (int)g;
  doc["b"] = (int)b;

  String response;
  serializeJson(doc, response);
//  server.send(200, "application/json", response);
}

Light side

Light side is worked as a client and Xiao C3 is used for Wifi communication.

As I don’t have enough time to focus on the light side at the first spiral, I use Neopixel. I’d like to improve light side such as stronger light. I also think about the network too.

It is used those libraries for network and light.

  • WiFi.h
  • HTTPClient.h
  • Adafruit_NeoPixel.h

This code is basically getting the color data

#include <WiFi.h>
#include <HTTPClient.h>
#include <Adafruit_NeoPixel.h>


    int r = doc["r"];
    int g = doc["g"];
    int b = doc["b"];
    Serial.printf("Received: R=%d, G=%d, B=%d\n", r, g, b);
    for(int i=0; i<NUM_LEDS; i++) { // For each pixel...
        strip.setPixelColor(i, strip.Color(r, g, b));
        strip.show();        
    }

Assembly

After cutting all the materials, I assembled them.

Final Test

After assembling all the parts, I tested the final check, working the controller and connecting the light(Neopixel).

Files

Controller

PCB

Code