Step by Step DIY Phone Stand With PicoBricks

by picoMaker in Circuits > Raspberry Pi

141 Views, 2 Favorites, 0 Comments

Step by Step DIY Phone Stand With PicoBricks

diy-phone-holder-diagram (600 x 500 piksel).jpg

In this project we are making a robotic phone stand using the Raspberry Pi kit PicoBricks


Features:

  1. You can get 3D output thanks to 3D STL files.
  2. You can control the phone stand with potentiometer.
  3. You can see the temperature and humidity of the room on the OLED screen.
  4. If you are in a dark environment, you can turn on LED light and illuminate the surroundings.

Supplies

diy-phone-holder-diagram (1).jpg

The following components on PicoBricks were used in the project:


Print 3D Files

In this step, you can download the STL files I shared with you and print them from your 3D printer:

Youtube Tutorials

How to Make Moving Robotic Phone Stand? | DIY Easy Tutorial

If you want, you can watch our Youtube tutorial video and do all the operations. If you want to do it by reading, you can continue from the article below.

Connect Raspberry Pi Pico to MicroPhyton

The first thing we need to do is to connect our Raspberry Pi Pico to MicoPhyton. You can find a step-by-step guide for this from this link:

https://picobricks.com/blogs/how-to/use-with-micropython

Upload Necessary Codes to PicoBricks

Below I am sharing the codes you need to install on your Raspberry Pi Pico kit PicoBricks. You can install these codes and start using your phone holder directly:


from time import sleep
from machine import Pin
from picobricks import DHT11
import time
from machine import I2C
from picobricks import SSD1306_I2C
import math
import machine
from machine import PWM
from math import fabs
from picobricks import WS2812


dht_sensor = DHT11(Pin(11))


dht_read_time = time.time()


temp = 0


def getTemp():
   global dht_read_time
   global temp
   if time.time() - dht_read_time >= 3:
       dht_read_time = time.time()
       try:
           dht_sensor.measure()
           temp = dht_sensor.temperature
       except Exception as e:
           pass
   return temp


i2c = I2C(0, scl=Pin(5), sda=Pin(4), freq=200000)
oled = SSD1306_I2C(128, 64, i2c, addr=0x3c)
dht_sensor = DHT11(Pin(11))


dht_read_time = time.time()


humidity = 0


def getHumidity():
   global dht_read_time
   global humidity
   if time.time() - dht_read_time >= 3:
       dht_read_time = time.time()
       try:
           dht_sensor.measure()
           humidity = dht_sensor.humidity
       except Exception as e:
           pass
   return humidity


pot = machine.ADC(26)
pwm_1 = PWM(Pin(21))
pwm_1.freq(50)
def CalculateAngle(angle):
   angle = fabs((angle * (6000 / 180)) + 2000)
   angle = round(angle)
   return angle


pin_button = machine.Pin(10, machine.Pin.IN)
ws2812 = WS2812(6, brightness = 1)


a = 0
while True:
    oled.fill(0)
    oled.text("{}".format(getTemp()), 95, 5)
    oled.text("{}".format(getHumidity()), 95, 25)
    oled.text("{}".format("Temp"), 5, 5)
    oled.text("{}".format("Humidity"), 5, 25)
    oled.text("{}".format("Press Button"), 5, 45)
    oled.text("{}".format("For Light"), 5, 55)
    oled.show()
    pwm_1.duty_u16(CalculateAngle(round( pot.read_u16() - 0 ) * ( 180 - 0 ) / ( 65535 - 0 ) + 0))
    if (pin_button.value()) and a == (0):
        ws2812.pixels_fill((255, 255, 255))
        ws2812.pixels_show()
        a = 1
        time.sleep((0.5))
    if (pin_button.value()) and a == (1):
        ws2812.pixels_fill((0 ,0 ,0 ))
        ws2812.pixels_show()
        a = 0
        time.sleep((0.5))