25 smart greenhouse project with picobricksCategoriesLed Raspberry Pi Pico Uncategorized

#25 Smart Greenhouse Project with PicoBricks

The rapid changes in climate due to the effect of global warming cause a decrease in productivity in agricultural activities. In the 1500s, Daniel Barbaro built the first known greenhouse in history. Greenhouses are suitable environments for growing plants that can provide controllable air, water, heat and light conditions.

In greenhouses, heaters are used to balance the heat, electric water motors for irrigation, fans are used to regulate humidity and to provide pollination. With the development of technology, the producer can follow the status of the greenhouse with his phone from anywhere and can do the work that needs to be done. The general name of this technology is Internet of Things (IOT).

Special sensors are used to measure temperature, humidity and oxygen content in greenhouses. In addition, special sensors measuring soil moisture are used to decide on irrigation. Electronically controlled drip irrigation systems are used to increase irrigation efficiency.

In this project, we will prepare a simple greenhouse with IOT technology and PicoBricks. We will use PicoBricks with the ESP8266 wifi module in this greenhouse. In this way, we will turn the greenhouse into an object that we can track over the Internet.

Details and Algorithm

The greenhouse model you will prepare will include a soil moisture sensor, and a DHT11 temperature and humidity sensor hanging from the top. A submersible pump will be placed in the water tank outside the model, and the hose coming out of the end of the pump will go to the ground in the greenhouse. Picoboard will be placed in a suitable place outside the greenhouse model.
When Picobricks starts, it starts to broadcast wifi thanks to the ESP8266 wifi module. When we enter the IP address of Esp8266 from the smart phone connected to the same network, we encounter the web page where we will control the Greenhouse. Here we can see the temperature and humidity values. If we wish, we can start the irrigation process by giving the irrigation command.

Components

1X PicoBricks
1X Pump
1X Soil Humidity Sensor
1X ESP8266 Wifi Module
PicoBricks Smart Greenhouse Kit
Jumper Cables
Easy Connection Cables

Wiring Diagram

You can code and run Picobricks’ modules without wiring. If you are going to use the modules by separating them from the board, you should make the module connections with grove cables.

Construction Stages of the Project

1-Detach the floor of the Greenhouse model from the SR-2 coded part in the Greenhouse kit.

2- Attach the pieces in the middle of the SR-3 piece to the floor of the Greenhouse.

3- Remove the inner walls of the greenhouse from the SR-4 part and attach it to the ground of the greenhouse.

4- Remove the Greenhouse arches in SR-1 and SR-3 and place them on the greenhouse floor.

5-Cover the rectangular area where soil will be placed with cling film. After irrigation, you will protect the model parts. Pour the plant soil into the greenhouse. Fill so that there is no empty space.

6- Insert the parts of the SR-4 into the notches on the greenhouse.

7-Thread the remaining two thin flat pieces of SR-4 through the holes on both sides of the greenhouse from the underside. This process makes the greenhouse more robust.

8- Pass the hose to the submersible pump. You will install an irrigation system similar to the drip irrigation system in the greenhouse. Pass the hose where you want the soil to be irrigated. Remember to cut the hose just enough to reach the water tank.

9- Place the DHT11 temperature and humidity sensor on the greenhouse model and the Soil Moisture Sensor in the soil.

10- Plug the Soil Moisture sensor to the pin number GPIO27 on the Picoboard and connect the 2 pen battery to the power input of the Picoboard. Place the submersible pump and the end of the hose in a deep container of water. Be careful not to get the motor drive wet.

MicroBlocks Codes of the PicoBricks

204240933 d479ef1b 959d 4160 8cec fc353e85cd26

You can access the Microblocks codes of the project by dragging the image to the Microblocks Run tab or click the button.

MicroPython Codes of the PicoBricks

				
					import utime
import uos
import machine 
from machine import Pin, ADC
from picobricks import DHT11  
from utime import sleep 

dht_sensor = DHT11(Pin(11))
smo_sensor=ADC(27)
m1 = Pin(22, Pin.OUT)
m1.low()

print("Machine: \t" + uos.uname()[4])
print("MicroPython: \t" + uos.uname()[3])

uart0 = machine.UART(0, baudrate=115200)
print(uart0)

def Connect_WiFi(cmd, uart=uart0, timeout=5000):
    print("CMD: " + cmd)
    uart.write(cmd)
    utime.sleep(7.0)
    Wait_ESP_Rsp(uart, timeout)
    print()
    
def Rx_ESP_Data():
    recv=bytes()
    while uart0.any()>0:
        recv+=uart0.read(1)
    res=recv.decode('utf-8')
    return res

def Send_AT_Cmd(cmd, uart=uart0, timeout=2000):
    print("CMD: " + cmd)
    uart.write(cmd)
    Wait_ESP_Rsp(uart, timeout)
    print()

def Wait_ESP_Rsp(uart=uart0, timeout=2000):
    prvMills = utime.ticks_ms()
    resp = b""
    while (utime.ticks_ms()-prvMills)<timeout:
        if uart.any():
            resp = b"".join([resp, uart.read(1)])
    print("resp:")
    try:
        print(resp.decode())
    except UnicodeError:
        print(resp)

Send_AT_Cmd('AT\r\n')          #Test AT startup
Send_AT_Cmd('AT+GMR\r\n')      #Check version information
Send_AT_Cmd('AT+CIPSERVER=0\r\n')   
Send_AT_Cmd('AT+RST\r\n')      #Check version information
Send_AT_Cmd('AT+RESTORE\r\n')  #Restore Factory Default Settings
Send_AT_Cmd('AT+CWMODE?\r\n')  #Query the WiFi mode
Send_AT_Cmd('AT+CWMODE=1\r\n') #Set the WiFi mode = Station mode
Send_AT_Cmd('AT+CWMODE?\r\n')  #Query the WiFi mode again
Send_AT_Cmd('AT+CWJAP="ID","Password"\r\n', timeout=5000) #Connect to AP
utime.sleep(3.0)
Send_AT_Cmd('AT+CIFSR\r\n')    #Obtain the Local IP Address
utime.sleep(3.0)
Send_AT_Cmd('AT+CIPMUX=1\r\n')    
utime.sleep(1.0)
Send_AT_Cmd('AT+CIPSERVER=1,80\r\n')    #Obtain the Local IP Address
utime.sleep(1.0)

while True:
    res =""
    res=Rx_ESP_Data()
    utime.sleep(2.0)
    if '+IPD' in res: # if the buffer contains IPD(a connection), then respond with HTML handshake
        id_index = res.find('+IPD')
        
        if '/WATERING' in res:
            print('Irrigation Start')
            m1.high()
            utime.sleep(10)
            m1.low()
            print('Irrigation Finished')
            connection_id =  res[id_index+5]
            print("connectionId:" + connection_id)
            print ('! Incoming connection - sending webpage')
            uart0.write('AT+CIPSEND='+connection_id+',200'+'\r\n')  
            utime.sleep(1.0)
            uart0.write('HTTP/1.1 200 OK'+'\r\n')
            uart0.write('Content-Type: text/html'+'\r\n')
            uart0.write('Connection: close'+'\r\n')
            uart0.write(''+'\r\n')
            uart0.write('<!DOCTYPE HTML>'+'\r\n')
            uart0.write('<html>'+'\r\n')
            uart0.write('<body><center><H1>CONNECTED...<br/></H1></center>'+'\r\n')
            uart0.write('<body><center><H1>Irrigation Complete.<br/></H1></center>'+'\r\n')
            uart0.write('<script>class RocketElementorAnimation{constructor(){this.deviceMode=document.createElement("span"),this.deviceMode.id="elementor-device-mode",this.deviceMode.setAttribute("class","elementor-screen-only"),document.body.appendChild(this.deviceMode)}_detectAnimations(){let t=getComputedStyle(this.deviceMode,":after").content.replace(/"/g,"");this.animationSettingKeys=this._listAnimationSettingsKeys(t),document.querySelectorAll(".elementor-invisible[data-settings]").forEach(t=>{const e=t.getBoundingClientRect();if(e.bottom>=0&&e.top<=window.innerHeight)try{this._animateElement(t)}catch(t){}})}_animateElement(t){const e=JSON.parse(t.dataset.settings),i=e._animation_delay||e.animation_delay||0,n=e[this.animationSettingKeys.find(t=>e[t])];if("none"===n)return void t.classList.remove("elementor-invisible");t.classList.remove(n),this.currentAnimation&&t.classList.remove(this.currentAnimation),this.currentAnimation=n;let s=setTimeout(()=>{t.classList.remove("elementor-invisible"),t.classList.add("animated",n),this._removeAnimationSettings(t,e)},i);window.addEventListener("rocket-startLoading",function(){clearTimeout(s)})}_listAnimationSettingsKeys(t="mobile"){const e=[""];switch(t){case"mobile":e.unshift("_mobile");case"tablet":e.unshift("_tablet");case"desktop":e.unshift("_desktop")}const i=[];return["animation","_animation"].forEach(t=>{e.forEach(e=>{i.push(t+e)})}),i}_removeAnimationSettings(t,e){this._listAnimationSettingsKeys().forEach(t=>delete e[t]),t.dataset.settings=JSON.stringify(e)}static run(){const t=new RocketElementorAnimation;requestAnimationFrame(t._detectAnimations.bind(t))}}document.addEventListener("DOMContentLoaded",RocketElementorAnimation.run);</script></body></html>'+'\r\n')
        elif '/SERA' in res:
            #sleep(1) # It was used for DHT11 to measure.
            dht_sensor.measure() # Use the sleep() command before this line.
            temp=dht_sensor.temperature
            hum=dht_sensor.humidity
            smo=round((smo_sensor.read_u16()/65535)*100)
            sendStr="\"TEMP\":{}, \"Humidity\":{}, \"S.Moisture\":{}%".format(temp,hum,smo)
            sendText="{"+sendStr+"}"
            strLen=46+len(sendText)
            connection_id =  res[id_index+5]
            print("connectionId:" + connection_id)
            print ('! Incoming connection - sending webpage')
            atCmd="AT+CIPSEND="+connection_id+","+str(strLen)
            uart0.write(atCmd+'\r\n') 
            utime.sleep(1.0)
            uart0.write('HTTP/1.1 200 OK'+'\r\n')
            uart0.write('Content-Type: text/html'+'\r\n')
            uart0.write(''+'\r\n')
            uart0.write(sendText+'\r\n')

        elif '/' in res:
            
            print("resp:")
            print(res)
            connection_id =  res[id_index+5]
            print("connectionId:" + connection_id)
            print ('! Incoming connection - sending webpage')
            uart0.write('AT+CIPSEND='+connection_id+',200'+'\r\n') 
            utime.sleep(3.0)
            uart0.write('HTTP/1.1 200 OK'+'\r\n')
            uart0.write('Content-Type: text/html'+'\r\n')
            uart0.write('Connection: close'+'\r\n')
            uart0.write(''+'\r\n')
            uart0.write('<!DOCTYPE HTML>'+'\r\n')
            uart0.write('<html>'+'\r\n')
            uart0.write('<body><center><H1>CONNECTED.<br/></H1></center>'+'\r\n')
            uart0.write('<center><h4>INFO:Get Sensor Data</br>WATERING:Run Water Pump</h4></center>'+'\r\n')
            uart0.write('</body></html>'+'\r\n')
        utime.sleep(4.0)
        Send_AT_Cmd('AT+CIPCLOSE='+ connection_id+'\r\n') # once file sent, close connection
        utime.sleep(3.0)
        recv_buf="" #reset buffer
        print ('Waiting For connection...')
				
			

Arduino C Codes of the PicoBricks

				
					#include <DHT.h>
#define RX 0
#define TX 1

#define LIMIT_TEMPERATURE     30
#define DHTPIN                11
#define DHTTYPE               DHT11
#define smo_sensor            27
#define motor                 22
#define DEBUG true

DHT dht(DHTPIN, DHTTYPE);
int connectionId;

void setup() {
  Serial1.begin(115200);
  dht.begin();
  pinMode(smo_sensor, INPUT);
  pinMode(motor, OUTPUT);

  sendData("AT+RST\r\n", 2000, DEBUG); // reset module
  sendData("AT+GMR\r\n", 1000, DEBUG); // configure as access point
  sendData("AT+CIPSERVER=0\r\n", 1000, DEBUG); // configure as access point
  sendData("AT+RST\r\n", 1000, DEBUG); // configure as access point
  sendData("AT+RESTORE\r\n", 1000, DEBUG); // configure as access point
  sendData("AT+CWMODE?\r\n", 1000, DEBUG); // configure as access point
  sendData("AT+CWMODE=1\r\n", 1000, DEBUG); // configure as access point
  sendData("AT+CWMODE?\r\n", 1000, DEBUG); // configure as access point
  sendData("AT+CWJAP=\"WIFI_ID\",\"WIFI_PASSWORD\"\r\n", 5000, DEBUG); // ADD YOUR OWN WIFI ID AND PASSWORD
  delay(3000);
  sendData("AT+CIFSR\r\n", 1000, DEBUG); // get ip address
  delay(3000);
  sendData("AT+CIPMUX=1\r\n", 1000, DEBUG); // configure for multiple connections
  delay(1000);
  sendData("AT+CIPSERVER=1,80\r\n", 1000, DEBUG); // turn on server on port 80
  delay(1000);
}

void loop() {
  if (Serial1.find("+IPD,")) {
    delay(300);
    connectionId = Serial1.read() - 48;
    String serialIncoming = Serial1.readStringUntil('\r');
    Serial.print("SERIAL_INCOMING:");
    Serial.println(serialIncoming);

    if (serialIncoming.indexOf("/WATERING") > 0) {
      Serial.println("Irrigation Start");
      digitalWrite(motor, HIGH);
      delay(1000); // 10 sec.
      digitalWrite(motor, LOW);
      Serial.println("Irrigation Finished");
      Serial.println("! Incoming connection - sending WATERING webpage");
      String html = "";
      html += "<html>";
      html += "<body><center><H1>Irrigation Complete.<br/></H1></center>";
      html += "</body></html>";
      espsend(html);
    }
    if (serialIncoming.indexOf("/SERA") > 0) {
      delay(300);

      float smo = analogRead(smo_sensor);
      float smopercent = (460-smo)*100.0/115.0 ; //min ve max değerleri değişken.
      Serial.print("SMO: %");
      Serial.println(smo);

      float temperature = dht.readTemperature();
      Serial.print("Temp: ");
      Serial.println(temperature);

      float humidity = dht.readHumidity();
      Serial.print("Hum: ");
      Serial.println(humidity);
      
      Serial.println("! Incoming connection - sending SERA webpage");
      String html = "";
      html += "<html>";
      html += "<body><center><H1>TEMPERATURE<br/></H1></center>";
      html += "<center><H2>";
      html += (String)temperature;
      html += " C<br/></H2></center>";

      html += "<body><center><H1>HUMIDITY<br/></H1></center>";
      html += "<center><H2>";
      html += (String)humidity;
      html += "%<br/></H2></center>";  
      
      html += "<body><center><H1>SMO<br/></H1></center>";
      html += "<center><H2>";
      html += (String)smopercent;
      html += "%<br/></H2></center>";  
          
      html += "</body></html>";
      espsend(html);
    }
    else
      Serial.println("! Incoming connection - sending MAIN webpage");
    String html = "";
    html += "<html>";
    html += "<body><center><H1>CONNECTED.<br/></H1></center>";
    html += "<center><a href='/SERA'><h4>INFO:Get Sensor Data</a></br><a href='/WATERING'>WATERING:Run Water Pump</a></h4></center>";
    html += "</body></html>";
    espsend(html);
    String closeCommand = "AT+CIPCLOSE=";  ////////////////close the socket connection////esp command
    closeCommand += connectionId; // append connection id
    closeCommand += "\r\n";
    sendData(closeCommand, 3000, DEBUG);

  }

}
//////////////////////////////sends data from ESP to webpage///////////////////////////

void espsend(String d)
{
  String cipSend = " AT+CIPSEND=";
  cipSend += connectionId;
  cipSend += ",";
  cipSend += d.length();
  cipSend += "\r\n";
  sendData(cipSend, 1000, DEBUG);
  sendData(d, 1000, DEBUG);
}

//////////////gets the data from esp and displays in serial monitor///////////////////////

String sendData(String command, const int timeout, boolean debug)
{
  String response = "";
  Serial1.print(command);
  long int time = millis();
  while ( (time + timeout) > millis())
  {
    while (Serial1.available())
    {
      char c = Serial1.read(); // read the next character.
      response += c;
    }
  }

  if (debug)
  {
    Serial.print(response); //displays the esp response messages in arduino Serial monitor
  }
  return response;
}
				
			

Project Image

Project Proposal 💡

In the smart greenhouse project, by adding an OLED screen to the greenhouse entrance, you can monitor the humidity and temperature values inside, and by adding sensors such as MQ2 gas sensor, carbon dioxide sensor, air quality sensor, you can monitor the weather inside the greenhouse via WiFi with your mobile phone. In addition, by adding a DC fan and relay to the greenhouse, you can turn the ventilation on and off according to the indoor air quality with a mobile phone via WiFi.

24 maze navigating robot project with picobricksCategoriesLed Raspberry Pi Pico Uncategorized

#24 Maze Navigating Robot Project with PicoBricks

Coding education is as old as the history of programming languages. Today, different products are used to popularize coding education and make it exciting and fun. The first of these is educational robots. Preparing and programming robots improves children’s engineering and coding skills. Robotics competitions are organized by institutions and organizations to popularize coding education and encourage teachers and students. One of these competitions is the Maze Solver Robot competitions. These robots learn how to solve the maze by wandering around in the maze and returning to the starting point. Then, when they start the labyrinth again, they try to reach their destination in the shortest way possible. Robots use infrared or ultrasonic distance sensors while learning the maze.

Smart robot vacuums used in homes and workplaces also work with logic close to the algorithms of maze-solver robots. Thanks to their algorithms that constantly check and map the obstacles, they try to complete their tasks without crashing into things. Most of the smart vacuums are equipped with LIDAR and infrared sensors that are designed for  high-precision laser measurements and obstacle detection.

In this project, we will make a simple robot that you can use to navigate your own maze.

Details and Algorithm

In this project, we will use the 2WD robot car kit that comes with the set. We will use the HC-SR04 ultrasonic distance sensor so that the robot can detect the walls in front of it and decide its movements. In the maze, the robot will scan the space in front of the car and move forward if it is empty. If there is a wall (obstacle) within 5 cm’s, the car will turn right and measure the distance again. If the new distance on the right is greater than 5 cm, it will continue on its way. If it is less, it will turn left and move forward. By turning right and left, we will guide the vehicle to make progress and exit the maze.

Components

1X PicoBricks
1X HC-SR04 Ultrasonic Sensor
2X DC Motor
Jumper Cables
Easy Connection Cables

Wiring Diagram

You can code and run Picobricks’ modules without wiring. If you are going to use the modules by separating them from the board, you should make the module connections with grove cables.

Construction Stages of the Project

You can build the robot car by following the steps for the 2WD robot car assembly in the voice-controlled car project.

We will not use the HC05 bluetooth module in this project.

In order to mount the HC-SR04 ultrasonic distance sensor on the robot, you can download the required parts from the link here and print it on the 3D printer and mount it on the vehicle.

After assembling the robot, you can use cardboard boxes to build the maze. You can make walls out of cardboard, or you can use 3D printed walls to connect the walls with hot glue to build the maze.

MicroBlocks Codes of the PicoBricks

204217878 2b198893 7572 4cdc 9f3b 173f71352f4a

You can access the Microblocks codes of the project by dragging the image to the Microblocks Run tab or click the button.

MicroPython Codes of the PicoBricks

				
					from machine import Pin
from utime import sleep
import utime
#define libraries

trigger = Pin(15, Pin.OUT)
echo = Pin(14, Pin.IN)
#define sensor pins

m1 = Pin(21, Pin.OUT)
m2 = Pin(22, Pin.OUT)
#define dc motor pins

m1.low()
m2.low()
signaloff = 0
signalon = 0

def getDistance():
   trigger.low()
   utime.sleep_us(2)
   trigger.high()
   utime.sleep_us(5)
   trigger.low()
   while echo.value() == 0:
       signaloff = utime.ticks_us()
   while echo.value() == 1:
       signalon = utime.ticks_us()
   timepassed = signalon - signaloff
   distance = (timepassed * 0.0343) / 2
   return distance
#calculate distance

measure=0
while True:
    
    measure=int(getDistance())
    print(measure)
    if measure>5:
        m1.high()
        m2.high()
        sleep(1) #if the distance is higher than 5, the wheels go straight
    else:
        m1.low()
        m2.low()
        sleep(0.5)
        m1.high()
        m2.low()
        sleep(0.5)
        measure=int(getDistance())
        if measure<5:
            m1.low()
        m2.low()
        sleep(0.5)
        m1.low()
        m2.high()
        sleep(0.5)
        #If the distance is less than 5, wait, move in any direction; if the distance is less than 5, move in the opposite direction
				
			

Arduino C Codes of the PicoBricks

				
					#include <NewPing.h>

#define TRIGGER_PIN  15
#define ECHO_PIN     14
#define MAX_DISTANCE 400
//define sensor pins

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

void setup() {
  pinMode(21,OUTPUT);
  pinMode(22,OUTPUT); //define dc motor pins
}

void loop() {
  
  delay(50);
  int distance=sonar.ping_cm();
  Forward();

  if(distance<5){

    Stop();
    delay(1000);
    Turn_Right();
    delay(1000);
    int distance=sonar.ping_cm();

    if(distance<5){
      Stop();
      delay(1000);
      Turn_Left();
      delay(500);
      // If the distance is less than 5, wait, turn right; if the distance is less than 5 again, move in the opposite direction
    }
  }
}

void Forward(){
  digitalWrite(21,HIGH);
  digitalWrite(22,HIGH); //if the distance is higher than 5, go straight
}
void Turn_Left(){
  digitalWrite(21,LOW);
  digitalWrite(22,HIGH); //turn left
}
void Turn_Right(){
  digitalWrite(21,HIGH);
  digitalWrite(22,LOW);  //turn right
}
void Stop(){
  digitalWrite(21,LOW);
  digitalWrite(22,LOW); //wait
}
				
			

Project Image

Project Proposal 💡

We used a HC-SR04 ultrasonic distance sensor, mounted to the front of the car, to navigate the maze. The algorithm used is very simple and relies on timed movements to navigate. You can enhance the code to use shorter timed movements and combine them with more sensor readings. Turns can be coded in a different way using this method, similar to the straight moves.

By using a servo motor, you can rotate the HC-SR04 module to the right and left, and detect the open paths without the vehicle turning. It will make the car progress faster. Or, you can develop the project by mounting 3 HC-SR04 ultrasonic distance sensors on the front, right and left side of the vehicle, measuring the distances in 3 directions at the same time and directing the vehicle towards the open paths.

23 air piano project with picobricksCategoriesLed Raspberry Pi Pico Uncategorized

#23 Air Piano Project with PicoBricks

With the development of electronic technology, musical instruments that are difficult to produce, expensive and producing high-quality sound have been digitized. Pianos are one of these instruments. Each key of digital pianos produces electrical signals at a different frequency. Thus, it can play 88 different notes from its speakers. Factors such as the delay time of the keys of digital instruments, the quality of the speaker, the resolution of the sound have appeared as the factors affecting the quality. In electric guitars, vibrations in strings are digitized instead of keys. On the other hand, In wind instruments, the notes played can be converted into electrical signals and recorded thanks to the high-resolution microphones plugged into the sound output. This development in electronic technology has facilitated access to high-cost musical instruments, music education has gained a wider variety and spread to a wider audience.

In this project we will make a simple piano that can play 7 notes with PicoBricks. The speaker of this piano will be the buzzer. The ultrasonic sensor will act as the keys of the piano.

Details and Algorithm

In this project, we will make a piano application using the HC-SR04 Ultrasonic distance sensor and the buzzer module on PicoBricks. We will make the buzzer play different notes according to the values ​​coming from the distance sensor, and we will create melodies by moving our hand closer to the sensor and away from it. In addition, we will instantly print the distance and played note information on the OLED screen.

Components

1X PicoBricks
1X HC-SR04 Ultrasonic Sensor
Jumper Cables
Easy Connection Cables

Wiring Diagram

You can code and run Picobricks’ modules without wiring. If you are going to use the modules by separating them from the board, you should make the module connections with grove cables.

Construction Stages of the Project

MicroBlocks Codes of the PicoBricks

204217525 e5d71f21 c5df 4b83 b965 b2accb92cbfe

You can access the Microblocks codes of the project by dragging the image to the Microblocks Run tab or click the button.

MicroPython Codes of the PicoBricks

				
					from machine import Pin, PWM, I2C
from utime import sleep
import utime       
from picobricks import SSD1306_I2C  
import _thread
#define the libraries

buzzer=PWM(Pin(20,Pin.OUT))
trigger = Pin(15, Pin.OUT)
echo = Pin(14, Pin.IN)
#define the input and Output pins

WIDTH  = 128                                            
HEIGHT = 64
#OLED screen settings

sda=machine.Pin(4)
scl=machine.Pin(5)
i2c=machine.I2C(0,sda=sda, scl=scl, freq=1000000)
#initialize digital pin 4 and 5 as an OUTPUT for OLED communication

oled = SSD1306_I2C(WIDTH, HEIGHT, i2c)

measure=0

def getDistance():
   trigger.low()
   utime.sleep_us(2)
   trigger.high()
   utime.sleep_us(5)
   trigger.low()
   while echo.value() == 0:
       signaloff = utime.ticks_us()
   while echo.value() == 1:
       signalon = utime.ticks_us()
   timepassed = signalon - signaloff
   distance = (timepassed * 0.0343) / 2
   return distance
#calculate distance

def airPiano():
    while True:
        global measure
        
        if measure>5 and measure<11:
            buzzer.duty_u16(4000)
            buzzer.freq(262)
            sleep(0.4)
           
        elif measure>10 and measure<16:
            buzzer.duty_u16(4000)
            buzzer.freq(294)
            sleep(0.4)
            
        elif measure>15 and measure<21:
            buzzer.duty_u16(4000)
            buzzer.freq(330)
            sleep(0.4)
            
        elif measure>20 and measure<26:
            buzzer.duty_u16(4000)
            buzzer.freq(349)
            sleep(0.4)
            
        elif measure>25 and measure<31:
            buzzer.duty_u16(4000)
            buzzer.freq(392)
            sleep(0.4)
            
        elif measure>30 and measure<36:
            buzzer.duty_u16(4000)
            buzzer.freq(440)
            sleep(0.4)
            
        elif measure>35 and measure<41:
            buzzer.duty_u16(4000)
            buzzer.freq(494)
            sleep(0.4)
        else:
            buzzer.duty_u16(0)

_thread.start_new_thread(airPiano, ())
#play the tone determined by the value of the distance sensor

while True:
    measure=int(getDistance())
    oled.text("Distance " + str(measure)+ " cm", 5,30)
    oled.show()
    sleep(0.01)
    oled.fill(0)
    oled.show()
#write the specified texts to the determined x and ye coordinates on the OLED screen
				
			

Arduino C Codes of the PicoBricks

				
					#include <Wire.h>
#include "ACROBOTIC_SSD1306.h"
#include <NewPing.h>

#define TRIGGER_PIN  15
#define ECHO_PIN     14
#define MAX_DISTANCE 400

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

#define T_C 262
#define T_D 294
#define T_E 330
#define T_F 349
#define T_G 392
#define T_A 440
#define T_B 493

const int Buzzer = 20;

void setup() {
  pinMode(Buzzer,OUTPUT);

  Wire.begin();  
  oled.init();                      
  oled.clearDisplay(); 

#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
#endif
}

void loop() {

  delay(50);
  int distance=sonar.ping_cm();

  if(distance>5 & distance<11)
  {
    tone(Buzzer,T_C);
  }

  else if(distance>10 & distance<16)
  {
    tone(Buzzer,T_D);
  }

  else if(distance>15 & distance<21)
  {
    tone(Buzzer,T_E);
  }

  else if(distance>20 & distance<26)
  {
    tone(Buzzer,T_F);
  }

  else if(distance>25 & distance<31)
  {
    tone(Buzzer,T_G);
  }

  else if(distance>30 & distance<36)
  {
    tone(Buzzer,T_A);
  }

  else if(distance>35 & distance<41)
  {
    tone(Buzzer,T_B);
  }

  else 
  {
    noTone(Buzzer);
  }

  oled.clearDisplay();
  oled.setTextXY(2,4);              
  oled.putString("Distance: ");
  oled.setTextXY(4,6);              
  String string_distance=String(distance);
  oled.putString(string_distance);
  oled.setTextXY(4,8);              
  oled.putString("cm");
}
				
			

Project Image

Project Proposal 💡

There is one instant button on PicoBricks. By connecting 7 buttons to Pico, you can make different notes play when each key is pressed, you can use buttons for octave value and beat times, and you can develop your piano project.

22 digital ruler project with picobricksCategoriesLed Raspberry Pi Pico Uncategorized

#22 Digital Ruler Project with PicoBricks

Many tools are used to measure length. One of the first that comes to mind is rulers.Our measuring instrument differs according to the place and size to measure. Tape measures are used in construction and architecture, and calipers are used for small objects that require millimeter precision. In addition, if it is desired to measure an area that needs both large and precise measurement, distance meters working with laser and infrared systems are used. Ultrasonography devices used in the health sector also work with the same logic, but convert their measurements into visuals.

In our project, we will use PicoBricks and an ultrasonic sensor to prepare a digital ruler that will display the distance value on the OLED screen when the button is pressed. Ultrasonic sensors detect distance according to the return times of the sound waves they emit.

Details and Algorithm

When the program starts, instructions are displayed on the OLED screen. After the user presses the button, a measurement is taken. The red LED stays on during the measurement, and then turns off. The measured value is added to the distance from the tip of the sensor to the back of the box. The final calculated value is displayed on the OLED display.

Components

1X PicoBricks
1X HC-SR04 Ultrasonic Sensor
Jumper Cables
Easy Connection Cables

Wiring Diagram

You can code and run Picobricks’ modules without wiring. If you are going to use the modules by separating them from the board, you should make the module connections with grove cables.

Construction Stages of the Project

To prepare the project, you need double-sided foam tape, a utility knife, a waste cardboard box of approximately 15x10x5 cm.

1) Cut the holes for the ultrasonic sensor, OLED screen, button LED module, buzzer, battery box to pass the cables with a utility knife.

2) Hang all the cables inside the box and attach the back of the modules to the box with double-sided foam tape. Connect the trig pin of the ultrasonic sensor to the GPIO14 pin and the echo pin to the GPIO15 pin. You should connect the VCC pin to the VBUS pin on the Picoboard.

3) After completing the cable connections of all modules, you can insert the 2-battery box into the power jack of the Picoboard and turn on the switch. That’s it for the digital ruler project!

MicroBlocks Codes of the PicoBricks

204217289 1f31e808 c9c1 4992 9ab6 f5909c672dac

You can access the Microblocks codes of the project by dragging the image to the Microblocks Run tab or click the button.

MicroPython Codes of the PicoBricks

				
					from machine import Pin, PWM, I2C
from utime import sleep
from picobricks import SSD1306_I2C
import utime
#define the libraries
redLed=Pin(7,Pin.OUT)
button=Pin(10,Pin.IN,Pin.PULL_DOWN)
buzzer=PWM(Pin(20,Pin.OUT))
buzzer.freq(392)
trigger = Pin(15, Pin.OUT)
echo = Pin(14, Pin.IN)
#define input and output pins
WIDTH  = 128                                            
HEIGHT = 64                                       
#OLED screen settings
sda=machine.Pin(4)
scl=machine.Pin(5)
i2c=machine.I2C(0,sda=sda, scl=scl, freq=1000000)
#initialize digital pin 4 and 5 as an OUTPUT for OLED communication
oled = SSD1306_I2C(128, 64, i2c)
measure=0
finalDistance=0

def getDistance():
   trigger.low()
   utime.sleep_us(2)
   trigger.high()
   utime.sleep_us(5)
   trigger.low()
   while echo.value() == 0:
       signaloff = utime.ticks_us()
   while echo.value() == 1:
       signalon = utime.ticks_us()
   timepassed = signalon - signaloff
   distance = (timepassed * 0.0343) / 2
   return distance
#calculate the distance
def getMeasure(pin):
    global measure
    global finalDistance
    redLed.value(1)
    for i in range(20):
        measure += getDistance()
        sleep(0.05)
    redLed.value(0)
    finalDistance = (measure/20) + 1
    oled.fill(0)
    oled.show()
    oled.text(">Digital Ruller<", 2,5)
    oled.text("Distance " + str(round(finalDistance)) +" cm", 0, 32)
    oled.show()
#print the specified distance to the specified x and y coordinates on the OLED screen
    print(finalDistance)
    buzzer.duty_u16(4000)
    sleep(0.05)
    buzzer.duty_u16(0)
    measure=0
    finalDistance=0
 #sound the buzzer  
button.irq(trigger=machine.Pin.IRQ_RISING, handler=getMeasure)
				
			

Arduino C Codes of the PicoBricks

				
					#include <Wire.h>
#include "ACROBOTIC_SSD1306.h"
#include <NewPing.h>
// define the libraries
#define TRIGGER_PIN  15
#define ECHO_PIN     14
#define MAX_DISTANCE 400

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

#define T_B 493

int distance = 0;
int total = 0;

void setup() {
  pinMode(7,OUTPUT);
  pinMode(20,OUTPUT);
  pinMode(10,INPUT); 
  // define input and output pins
  Wire.begin();  
  oled.init();                      
  oled.clearDisplay(); 


}

void loop() {

  delay(50);
  if(digitalRead(10) == 1){

    int measure=0;
    digitalWrite(7,HIGH);
    tone(20,T_B);
    delay(500);
    noTone(20);

    for (int i=0;i<20;i++){

      measure=sonar.ping_cm();
      total=total+measure;
      delay(50);      
    }

    distance = total/20+6; // calculate the distance
    digitalWrite(7,LOW);

    delay(1000);
    oled.clearDisplay();
    oled.setTextXY(2,1);              
    oled.putString(">Digital Ruler<");
    oled.setTextXY(5,1);              
    oled.putString("Distance: ");
    oled.setTextXY(5,10);              
    String string_distance=String(distance);
    oled.putString(string_distance);
    oled.setTextXY(5,12);              
    oled.putString("cm"); // print the calculated distance on the OLED screen

    measure=0;
    distance=0;
    total=0;
  }
}
				
			

Project Image

Project Proposal 💡

You can turn the digital ruler into a height meter by fixing it to the wall or ceiling. Since the height meter will be fixed on the wall or ceiling, it will not be possible to measure by pressing the button. For this, you can add the HC05 bluetooth module to the project and have it measure when a command is received from the mobile application.

21 automatic trash bin project with picobricksCategoriesLed Raspberry Pi Pico Uncategorized

#21 Automatic Trash Bin Project with PicoBricks

The Covid 19 pandemic has changed people’s daily routines. In many areas, such as cleaning, working, shopping and social life, people were introduced to a series of new rules that they had to comply with. Covid-19 has LED to the development of new business areas as well as some products that stand out. At a time when hand hygiene was very important, no one wanted to touch the lid of the trash cans to throw away their garbage.

Trash bins that open automatically when approached, and when full, make bags ready to be thrown away, found buyers at prices far above their cost. In addition, automatic disinfectant machines provided contactless hygiene by pouring a certain amount of liquid into our palms when we held our hands under them. Automatic disinfectant machines took place on the shelves at prices well above their cost. These two products have similarities in terms of their working principles. In automatic disinfectant machines, a pump with an electric motor or a servo motor, dispenses the liquid. In automatic trash bins, a servo motor that opens the lid was used, and infrared or ultrasonic sensors were used to detect hand movement. 

In this project, you will make an automatic stylish trash bin for your room using an ultrasonic sensor and servo motor with PicoBricks.

Details and Algorithm

HC-SR04 ultrasonic distance sensor and SG90 servo motor will be used in this project. When the user puts his hand in front of the lid of the trash can, the distance sensor will detect the proximity and notify  the program. Your program will then open the lid of the garbage can by running a servo motor and will close it again after a short while.

Components

1X PicoBricks
1X HC-SR04 Ultrasonic Sensor
1X Servo Motor
Jumper Cables
Easy Connection Cables

Wiring Diagram

You can code and run Picobricks’ modules without wiring. If you are going to use the modules by separating them from the board, you should make the module connections with grove cables.

Construction Stages of the Project

You can download the 3D drawing files of the project from this link and get 3D printing.

1: Fix it by screwing it to the trash bin cover of the servo motor apparatus.

2: Fix the ultrasonic distance sensor on the lid of the trash bin with the hot glue.

3: Pass the cables of the ultrasonic distance sensor through the hole in the box and connect them to the pins shown in the PicoBricks circuit diagram, make the servo motor and motor driver connections.

4: Fix the servo motor, PicoBricks and motor driver parts to the box with hot glue.

If everything went well, when you put your hand close to the garbage can, the lid of the bucket will open and it will close again after you throw the garbage away.

MicroBlocks Codes of the PicoBricks

204217176 b1f2f9f2 97a3 4f2c 852b 60f9d618a3c9

You can access the Microblocks codes of the project by dragging the image to the Microblocks Run tab or click the button.

MicroPython Codes of the PicoBricks

				
					from machine import Pin, PWM
from utime import sleep

servo=PWM(Pin(21,Pin.OUT))
trigger = Pin(15, Pin.OUT)
echo = Pin(14, Pin.IN)

servo.freq(50)
servo.duty_u16(1920) #15 degree

def getDistance():
   trigger.low()
   utime.sleep_us(2)
   trigger.high()
   utime.sleep_us(5)
   trigger.low()
   while echo.value() == 0:
       signaloff = utime.ticks_us()
   while echo.value() == 1:
       signalon = utime.ticks_us()
   timepassed = signalon - signaloff
   distance = (timepassed * 0.0343) / 2
   print("The distance from object is ",distance,"cm")
   return distance

while True:
    sleep(0.01)
    if int(getDistance())<=10:
        servo.duty_u16(4010) #70 degree
        utime.sleep(0.3)
        servo.duty_u16(1920)
				
			

Arduino C Codes of the PicoBricks

				
					#include <Servo.h>
#define trigPin 14
#define echoPin 15
Servo servo;
void setup() {
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  servo.attach(21);
}

void loop() {
  long duration, distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1; 
  if (distance < 80) {
    Serial.print(distance);
    Serial.println(" cm");
    servo.write(179);
  }

  else if (distance<180) {
    Serial.print(distance);
    Serial.println(" cm");
    servo.write(100); 
  }
  

}
				
			

Project Image

Project Proposal 💡

As in this project, where we automate a trash can in our house using sensors and motors, you can have a drawer or a cabinet door open automatically with the help of sensors and motors.

20 secured entrance project with picobricksCategoriesLed Raspberry Pi Pico Uncategorized

#20 Secured Entrance Project with PicoBricks

Security systems include technologies that can control access at building and room entrances. Card entry systems, in which only authorized personnel can enter the operating rooms of hospitals, are one of the first examples that come to mind. In addition, many entrance areas are equipped with card and password entry technologies. These electronic systems not only prevent the entrance of unauthorized persons, but also ensure that entry and exit information is recorded. Password entry, card entry, fingerprint scanning, face scanning, retina scanning and voice recognition technologies are the authentication methods used in electronic entry systems.

Systems such as RFID and NFC are the basic forms of contactless payment technologies today. Although the contactless payment technology used with credit cards is technically different, the working logic is the same. The maximum distance between the reader and the card is one of the features that distinguishes the technologies from each other. When leaving the shopping stores, especially clothing stores, NFC tags on the products will beep if they are detected by the readers at the entrance. A kind of RFID technology is used in those systems.

In this project, we will prepare a card entry system on a model house. The electronic components we will use are MFRC522 RFID reader and 13.56 Mhz cards.

Details and Algorithm

Place the MFRC522 reader near the door of the model so that it is visible from the outside. Place the RGB LED and the buzzer on the wall where the door is visible from the outside. Picoboard can remain in the model. The entrance door of the model should be connected to the door of the servo, while the servo is set to 0 degrees, the door should be closed. You should determine the serial number of the RFID / NFC tag that will open the door, create the homeowner variable and assign the serial number to this variable.

Set the door to the closed position when the program starts. Make the buzzer beep when a card is shown to the RFID reader. If the serial number of the card being read matches the serial number in the homeowner variable, turn the RGB LED on green. Then let the door open. Make sure the door is closed 3 seconds after the door is opened. If the serial number of the card being read does not match the homeowner variable, turn the RGB LED on red and play a different tone from the buzzer.

Components

1X PicoBricks
1X Servo Motor
1X RC522-RFID Card
Jumper Cables
Easy Connection Cables

Wiring Diagram

You can code and run Picobricks’ modules without wiring. If you are going to use the modules by separating them from the board, you should make the module connections with grove cables.

Construction Stages of the Project

We will make the project on the house model you used in the Smart Home project number 18.

Click for Smart Home project

Drill holes for the RGB LED, Buzzer and RC522 RFID reader on the house model.

Attach double-sided foam tape on the back of the RGB LED and Buzzer and attach it on the box. Place the RC522 inside the model as in the image.

Attach the servo motor to the inside of the model with double-sided tape as a hinge in the upper left corner of the door. Attach the servo head to the door with hot glue or liquid glue.

Finally, place the Pico board and the 2-key battery box inside the model house and complete the cable connections. After making the final checks of your project, it is ready to work.

MicroBlocks Codes of the PicoBricks

204216748 81713fb0 111e 4a8c 9ba1 d7372c11f440

You can access the Microblocks codes of the project by dragging the image to the Microblocks Run tab or click the button.

MicroPython Codes of the PicoBricks

The code to be run to learn the Card ID:

				
					from machine import Pin, SPI
from mfrc522 import MFRC522
import utime
#define libraries
sck = Pin(18, Pin.OUT)
mosi = Pin(19, Pin.OUT)
miso = Pin(16, Pin.OUT)
sda = Pin(17, Pin.OUT)
rst = Pin(15, Pin.OUT)
spi = SPI(0, baudrate=100000, polarity=0, phase=0, sck=sck, mosi=mosi, miso=miso)
rdr = MFRC522(spi, sda, rst)
#define MFRC522 pins

while True:
    (stat, tag_type) = rdr.request(rdr.REQIDL)
    if stat == rdr.OK:
        (stat, raw_uid) = rdr.anticoll()
        if stat == rdr.OK:
            uid = ("0x%02x%02x%02x%02x" % (raw_uid[0], raw_uid[1], raw_uid[2], raw_uid[3]))
            print(uid)
            utime.sleep(1)
            #read the card and give the serial number of the card
				
			

Project code:

				
					from machine import I2C, Pin, SPI, PWM
from mfrc522 import MFRC522
from ws2812 import NeoPixel
from utime import sleep 

servo = PWM(Pin(21))
servo.freq(50)
servo.duty_u16(1350) #servo set 0 angle 8200 for 180.

buzzer = PWM(Pin(20, Pin.OUT))
buzzer.freq(440)

neo = NeoPixel(6, n=1, brightness=0.3, autowrite=False)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLACK = (0, 0, 0)

sck = Pin(18, Pin.OUT)
mosi = Pin(19, Pin.OUT)
miso = Pin(16, Pin.OUT)
sda = Pin(17, Pin.OUT)
rst = Pin(15, Pin.OUT)
spi = SPI(0, baudrate=100000, polarity=0, phase=0, sck=sck, mosi=mosi, miso=miso)
homeowner = "0x734762a3"
rdr = MFRC522(spi, sda, rst)

while True:
    
    (stat, tag_type) = rdr.request(rdr.REQIDL)
    if stat == rdr.OK:
        (stat, raw_uid) = rdr.anticoll()
        if stat == rdr.OK:
            buzzer.duty_u16(3000)
            sleep(0.05)
            buzzer.duty_u16(0)
            uid = ("0x%02x%02x%02x%02x" % (raw_uid[0], raw_uid[1], raw_uid[2], raw_uid[3]))
            print(uid)
            sleep(1)
            if (uid==homeowner):
                neo.fill(GREEN)
                neo.show()
                servo.duty_u16(6000)
                sleep(3)
                servo.duty_u16(1350)
                neo.fill(BLACK)
                neo.show()
               
            else:
                neo.fill(RED)
                neo.show()
                sleep(3)
                neo.fill(BLACK)
                neo.show()
                servo.duty_u16(1350)
				
			

Arduino C Codes of the PicoBricks

The code to be run to learn the Card ID:

				
					#include <SPI.h>
#include <MFRC522.h>
//define libraries

int RST_PIN = 26;
int SS_PIN = 17;
//define pins

MFRC522 rfid(SS_PIN, RST_PIN);

void setup()
{
  Serial.begin(9600);
  SPI.begin();
  rfid.PCD_Init();
}

void loop() {

  if (!rfid.PICC_IsNewCardPresent())
    return;
  if (!rfid.PICC_ReadCardSerial())
    return;
    rfid.uid.uidByte[0] ;
    rfid.uid.uidByte[1] ;
    rfid.uid.uidByte[2] ;
    rfid.uid.uidByte[3] ; 
    printid();
  rfid.PICC_HaltA();
//Reading your ID.
}
void printid() 
{
  Serial.print("Your ID: ");
  for (int x = 0; x < 4; x++) {
    Serial.print(rfid.uid.uidByte[x]);
    Serial.print(" ");
  }
  Serial.println("");
}
				
			

Project code:

				
					#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h>
#include <Adafruit_NeoPixel.h>
//Define libraries.


#define RST_PIN    26
#define SS_PIN     17
#define servoPin   22
#define PIN        6 
#define NUMPIXELS  1
#define buzzer     20
//define pins of servo,buzzer,neopixel and rfid.

Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
Servo motor;
MFRC522 rfid(SS_PIN, RST_PIN);

byte ID[4] = {"Write your own ID."};

void setup() { 
  pixels.begin();
  motor.attach(servoPin);
  Serial.begin(9600);
  SPI.begin();
  rfid.PCD_Init();
  pinMode(buzzer, OUTPUT);
  
}
 
void loop()
{
  pixels.clear();
  
  if ( ! rfid.PICC_IsNewCardPresent())
    return;
  if ( ! rfid.PICC_ReadCardSerial())
    return;

  if 
  (
    rfid.uid.uidByte[0] == ID[0] &&
    rfid.uid.uidByte[1] == ID[1] &&
    rfid.uid.uidByte[2] == ID[2] &&
    rfid.uid.uidByte[3] == ID[3] ) 
  {
        Serial.println("Door Opened.");
        printid();
        tone(buzzer,523);
        delay(200);
        noTone(buzzer);
        delay(100);
        tone(buzzer,523);
        delay(200);
        noTone(buzzer);
        pixels.setPixelColor(0, pixels.Color(0, 250, 0));
        delay(200);
        pixels.show();
        pixels.setPixelColor(0, pixels.Color(0, 0, 0));
        delay(200);
        pixels.show();
        motor.write(180);
        delay(2000);
        motor.write(0);
        delay(1000);
     //RGB LED turns green and the door opens thanks to the servo motor if the correct card is read to the sensor.
    }
    else
    {
      Serial.println("Unknown Card.");
      printid();
      tone(buzzer,494);
      delay(200);
      noTone(buzzer);
      delay(100);
      tone(buzzer,494);
      delay(200);
      noTone(buzzer);
      pixels.setPixelColor(0, pixels.Color(250, 0, 0));
      delay(100);
      pixels.show();
      pixels.setPixelColor(0, pixels.Color(0, 0, 0));
      delay(100);
      pixels.show();
      //RGB LED turns red and the door does not open if the wrong card is read to the sensor
    }
  rfid.PICC_HaltA();
}
void printid()
{
  Serial.print("ID Number: ");
  for(int x = 0; x < 4; x++){
    Serial.print(rfid.uid.uidByte[x]);
    Serial.print(" ");
  }
  Serial.println("");
}
				
			

Project Proposal 💡

You can assign personal names to RFID cards and add an OLED screen to the project. When the card is read, you can print the name of the person to whom the card belongs, on the OLED screen.

19 hungry piggy bank project with picobricksCategoriesLed Raspberry Pi Pico Uncategorized

#19 Hungry Piggy Bank Project with PicoBricks

Ultrasonic sensors send out sound waves at a frequency that our ears cannot detect and produce distance information by calculating the return time of the reflected sound waves. We, the programmers, develop projects by making sense of the measured distance and the changes in distance. Parking sensors in the front and back of the cars are the places where ultrasonic sensors are most common in daily life. Do you know the creature that finds its way in nature with this method? Because bats are blind, they find their way through the reflections of the sounds they make.

Many of us like to save money. It is a very nice feeling that the money we save little by little is useful when needed. In this project, you will make yourself a very enjoyable and cute piggy bank. You will use the servo motor and ultrasonic distance sensor while making the piggy bank.

Details and Algorithm

HC-SR04 ultrasonic distance sensor and SG90 servo motor will be used in this project. As the user places money in the hopper of the piggy bank, the distance sensor will detect the proximity and signal PicoBricks. PicoBricks will operate the servo motor and raise the arm, drop the money into the piggy bank, and then the arm will go down again.

Components

1X PicoBricks
1X HC-SR04 Ultrasonic Sensor
1X Servo Motor
Jumper Cables
Easy Connection Cables

Wiring Diagram

You can code and run Picobricks’ modules without wiring. If you are going to use the modules by separating them from the board, you should make the module connections with grove cables.

Construction Stages of the Project

You can access the original files and construction stages of the project by clicking here. Unlike the project in this link, we will use the HC-SR04 ultrasonic distance sensor. You can download the updated 3D drawing files according to the HC-SR04 ultrasonic distance sensor from this link and get 3D printing.

1: Fix the plastic apparatus of the servo motor to the piggy bank arm with 2 screws.

2: Fix the second part of the piggy bank arm with the M3 screw and nut to the first part where the hopper is.

3: Pass the servo motor cable and place it in its slot.

4: Place the servo motor and its housing on the body of the piggy bank. You can use hot glue here.

5: Place the ultrasonic distance sensor in the piggy bank body and fix it with hot glue.

6: Attach the piggy bank arm to the servo motor and fix it to the top cover with M3 screws.

7: Fix the piggy bank arm to the body with M2 screw.

8: Plug the cables of the servo motor and ultrasonic distance sensor and connect the power cables.

9: According to the circuit diagram, connect the cables of the servo motor and ultrasonic distance sensor to the pico.

10: Plug Pico’s USB cable and reassemble the cables and attach the bottom cover. That is all.

MicroBlocks Codes of the PicoBricks

204216510 b30866f6 2f7c 401b bdc5 e42a18219b40

You can access the Microblocks codes of the project by dragging the image to the Microblocks Run tab or click the button.

MicroPython Codes of the PicoBricks

				
					from machine import Pin, PWM
import utime
#define the libraries

servo=PWM(Pin(21,Pin.OUT))
trigger = Pin(15, Pin.OUT)
echo = Pin(14, Pin.IN)
#define the input and output pins

servo.freq(50)
servo.duty_u16(6750)

def getDistance():
   trigger.low()
   utime.sleep_us(2)
   trigger.high()
   utime.sleep_us(5)
   trigger.low()
   while echo.value() == 0:
       signaloff = utime.ticks_us()
   while echo.value() == 1:
       signalon = utime.ticks_us()
   timepassed = signalon - signaloff
   distance = (timepassed * 0.0343) / 2
   print("The distance from object is ",distance,"cm")
   return distance
#calculate distance
while True:
    utime.sleep(0.01)
    if int(getDistance())<=5:  #if the distance variable is less than 5
        servo.duty_u16(4010) 
        utime.sleep(0.3)  #wait
        servo.duty_u16(6750)  
				
			

Arduino C Codes of the PicoBricks

				
					#include <Servo.h>
#define trigPin 15
#define echoPin 14
//define the libraries
Servo servo;
void setup() {
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  //define the input and output pins
  servo.attach(21); //define the servo pin
}
void loop() {
  long duration, distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
  //calculate distance
  if (distance < 5) {    //if the distance variable is less than 5
    Serial.print(distance);
    Serial.println(" cm");
    servo.write(179);
  }
  else if (distance>5) {   // if the distance variable is greater than 5
    Serial.print(distance);
    Serial.println(" cm");
    servo.write(100);
  }
}
				
			

Project Image

Project Proposal 💡

By adding an RGB LED module to the project, you can turn on the light in any color you want for each coin drop. By using the buzzer, a sound can be emitted every time a coin is dropped. You can also print the number of coin drops on the OLED screen.

16 voice controlled robot car project with picobricksCategoriesLed Raspberry Pi Pico Uncategorized

#16 Voice Controlled Robot Car Project with PicoBricks

Artificial intelligence applications are attempting to recognize human characteristics and learn and try to behave like people. We can define artificial intelligence crudely as software that can learn. Learning can happen through images, sound, and data collected  from the sensors. Algorithms used help in the decision-making processes in various areas AI is deployed. Artificial intelligence applications are now used in situations where the decision-making process needs to be done quickly and without errors. From the marketing to the defense industry, from education to health, from economy to entertainment, artificial intelligence increases efficiency and reduces costs. 

In this PicoBricks project, we will make a 2WD car that you can control by talking. PicoBricks bluetooth module allows you to control wirelessly 2 6V DC motors.

Details and Algorithm

The robot car kit that comes with the set will be assembled. The car is controlled via a mobile phone APP. The HC05 bluetooth module enables us to communicate wirelessly between PicoBricks and a mobile phone. Thanks to a mobile application installed on the mobile phone, the commands spoken into the phone will be transmitted to PicoBricks via Bluetooth  and the robot car will move according to this data. We can direct the robot car with the forward, backward, right, left, stop  voice commands.

Components

1X PicoBricks
2X 6V DC Motor
1X HC05 Bluetooth Module

Wiring Diagram

You can code and run Picobricks modules without wiring. If you are going to use the modules by separating them from the board, you should make the module connections with grove cables.

Construction Stages of the Project

1) Screw the first motor to the chassis of the 2WD robot car that comes out of the set and fix it.

1 1 1

2) Fix the second motor by screwing it to the chassis.

3) Attach the wheels to the motors.

4) Fix the caster under the chassis using spacers.

5) Fix the spacer with the nut from the top of the chassis.

6) Fix 4 spacers on the four corners of the lower chassis.

7) Fix the upper chassis with plug and nuts.

8) Connect the cables of the motors to the terminals on the motor driver.

9) Fix the motor driver, Bluetooth module, PicoBricks board and battery box to the chassis using hot silicone.

In this project, we move the robot car by giving it voice commands via a mobile application.

Instead of the car, you can also control the pan-tilt mechanism in the two-axis robot arm project using the same method. Likewise, you can try a mobile application where you can use buttons instead of voice commands, or you can develop your own application with the MIT Appinventor.

With the HC05 Bluetooth module, you can operate not only the motor driver and motor, but also other modules on PicoBricks. For example, you can light the RGB LED in any color you want, read the temperature and humidity values from the DHT11 module, the light values on the LDR sensor, and print text on the OLED screen.

There is a special mobile application written with the MIT Appinventor, and one in Microblocks to demonstrate this interactivity. You can test all these features by downloading the ZIP file from the link below.

There are two files in the ZIP archive:

  1. A MicroBlocks program  – PicoBricks BT Demo2
  2. An Android APK – PicoBricks_Remote_BKGND.apk

Extract and install the APK file to your mobile phone. Extract and save the MicroBlocks program to your PC. You need to run both of them at the same time and have a Bluetooth module installed in its slot on the PicoBricks board.

DOWNLOAD Link for the Android APP and associated MicroBlocks program

 

For the Android APP:

10

The screen layout of the APP resembles the PicoBricks board layout, with buttons representing the modules and a module map at the bottom of the screen. When you select a module to test, its name will turn yellow in the button and the corresponding module location on the map will display in orange color the module you are exercising.

First thing you need to do is to PAIR your phone Bluetooth settings with the HC-05. Refer to your device’s instructions on how to do that. Once you are paired, you can start using the Demo APP.

In the APP, click CONNECT to establish the bluetooth connection to the PicoBricks. You’ll see your BT module lights switch to a double blink every two seconds. Now you are ready to test.

Modules LED, DHT, RELAY, LDR, BUZZER operate with a single click of their respective buttons on the phone. LED and RELAY will turn on when tapped, and turn off at next tap. DHT, LDR will provide a sensor readout when tapped, which are displayed on the phone. BUZZER will make a short buzz sound.

Module POT will prompt to operate the potentiometer on the PicoBoard and display pot values on the OLED and the phone.Tap the POT button again when done.

Module NEO will display three sliders to control the RGB colors. As you adjust them, the NEOPixel on the PicoBricks and the NEO button background will change color simultaneously, showing you the resulting color selection. Tap the NEO button again when done.

Module OLED opens up a text entry area where you can type short messages. As you start typing, the Android keyboard will pop up for data entry. When you are done entering text, hide the keyboard and then tap the “SEND TO OLED” button. your message will be displayed on the OLED display of the PicoBricks. Tap the OLED button again when done.

Module MOTOR will display a slider that will let you control a SERVO motor attached to the PicoBricks. NOTE that the demo only operates SERVO #2. You can exercise a -90 to +90 degrees of motion with the servo motor. Tap the MOTOR button again when done.

It is possible that during the operation BT connection may drop or you may experience message synch problems between the phone and the PicoBricks unit. These programs were written to demo the concepts and do not contain rigorous error checking. Best course of action is to restart everything and try again.

 

Mobile companion APP:

You can download the mobile application for android devices from the link below and install it on the phone.

Download Link

 

 

Remember that since this is a Bluetooth APP, you need to set your phone Bluetooth option on and pair it with the HC05 on the PicoBricks. See your phone’s instruction manual on how to do this.

11 3

You can change the language of the APP with the Language button and select another one from the menu. Just remember that the project code in MicroBlocks is programmed to expect English commands. If you change your voice control language in the APP, then you also need to change the command strings in the MicroBlocks program.

MicroBlocks Codes of the PicoBricks

204213435 9b080b50 2bbf 4a84 b941 586b112e2110

You can access the Microblocks codes of the project by dragging the image to the Microblocks Run tab or click the button.

MicroPython Codes of the PicoBricks

				
					from machine import Pin, UART
from utime import sleep

uart = UART(0,9600) #If connection cannot be established, try 115200.
m1 = Pin(21, Pin.OUT)
m2 = Pin(22, Pin.OUT)

m1.low()
m2.low()

while True:
    sleep(0.05)
    if uart.any():
        cmd = uart.readline()
    if cmd==b'F':
        m1.high()
        m2.high()
    elif cmd==b'R':
        m1.high()
        m2.low()
    elif cmd==b'L':
        m1.low()
        m2.high()
    elif cmd==b'S':
        m1.low()
        m2.low()
    cmd=""
				
			

Arduino C Codes of the PicoBricks

				
					void setup() {
  Serial1.begin(9600);
}

void loop() {
  if (Serial1.available() > 0) {
 
      char sread = Serial1.read();
      Serial.println(sread);
      
      if (sread == 'f') {
      Forward();
    } else if(sread == 'r'){
      Turn_Right();
    } else if(sread == 'l'){
      Turn_Left();
    } else if(sread == 's'){
      Stop();
    }
  }
}

void Forward(){
  digitalWrite(21,HIGH);
  digitalWrite(22,HIGH);
  delay(1000);
  digitalWrite(21,LOW);
  digitalWrite(22,LOW);
}
void Turn_Left(){
  digitalWrite(21,LOW);
  digitalWrite(22,HIGH);
  delay(500);
  digitalWrite(21,LOW);
  digitalWrite(22,LOW);
}
void Turn_Right(){
  digitalWrite(21,HIGH);
  digitalWrite(22,LOW);
  delay(500);
  digitalWrite(21,LOW);
  digitalWrite(22,LOW);
}
void Stop(){
  digitalWrite(21,LOW);
  digitalWrite(22,LOW);
  delay(1000);
}
				
			

Project Image

15 night and day project with picobricksCategoriesLed Raspberry Pi Pico Uncategorized

#15 Night and Day Project with PicoBricks

How about playing the Night and Day game you played at school electronically? The game of night and day is a game in which we put our head on the table  when our teacher says night, and raise our heads when our teacher says day. This game will be a game that you will use your attention and reflex. In this project, we will use a 0.96” 128×64 pixel I2C OLED display. Since OLED screens can be used as an artificial light source, you can enlarge the characters on the screen using lenses and mirrors and reflect them on the desired plane. Systems that can reflect road and traffic information on smart glasses and automobile windows can be made using OLED screens.

Light sensors are sensors that can measure the light levels of the environment they are in, also called photodiodes. The electrical conductivity of the sensor exposed to light changes. We can control the light sensor by coding and developing electronic systems that affect the amount of light.

Details and Algorithm

First we will ask the player to press the button to start the game. Then we will make the OLED screen display NIGHT and DAY randomly for 2 seconds each. If the word NIGHT is displayed, the player should cover the LDR sensor; and if the word DAY is displayed, uncover it. The player has 2 secs to act. Each correct response of the player will earn 10 points. In case of wrong response, the game will be over and a different tone will sound from the buzzer. The score will be displayed on the OLED screen. If the player gives a total of 10 correct responses and gets 100 points, the phrase “Congratulations” will be displayed on the OLED screen and the buzzer will play notes in different tones.

Components

1X PicoBricks

Wiring Diagram

You can code and run Picobricks modules without wiring. If you are going to use the modules by separating them from the board, you should make the module connections with grove cables.

MicroBlocks Codes of the PicoBricks

204213242 feab9c4e 59f2 47fa 8106 014c8d9c815b

You can access the Microblocks codes of the project by dragging the image to the Microblocks Run tab or click the button.

MicroPython Codes of the PicoBricks

				
					from machine import Pin, I2C, Timer, ADC, PWM
from picobricks import SSD1306_I2C
import utime
import urandom
#define the libraries
WIDTH = 128
HEIGHT = 64
#OLED Screen Settings
sda=machine.Pin(4)
scl=machine.Pin(5)
#initialize digital pin 4 and 5 as an OUTPUT for OLED Communication
i2c=machine.I2C(0,sda=sda, scl=scl, freq=1000000)
oled = SSD1306_I2C(WIDTH, HEIGHT, i2c)
buzzer = PWM(Pin(20))
buzzer.freq(440)
ldr=ADC(Pin(27))
button=Pin(10,Pin.IN,Pin.PULL_DOWN)
#define the input and output pins
oled.text("NIGHT and DAY", 10, 0)
oled.text("<GAME>", 40, 20)
oled.text("Press the Button", 0, 40)
oled.text("to START!", 40, 55)
oled.show()
#OLED Screen Texts Settings
def changeWord():
    global nightorday
    oled.fill(0)
    oled.show()
    nightorday=round(urandom.uniform(0,1))
    #when data is '0', OLED texts NIGHT
    if nightorday==0:
        oled.text("---NIGHT---", 20, 30)
        oled.show()
    else:
        oled.text("---DAY---", 20, 30)
        oled.show()
    #waits for the button to be pressed to activate
        
while button.value()==0:
    print("Press the Button")
    sleep(0.01)
    
oled.fill(0)
oled.show()
start=1
global score
score=0
while start==1:
    global gamerReaction
    global score
    changeWord()
    startTime=utime.ticks_ms()
    #when LDR's data greater than 2000, gamer reaction '0'
    while utime.ticks_diff(utime.ticks_ms(), startTime)<=2000:
        if ldr.read_u16()>20000:
            gamerReaction=0
        #when LDR's data lower than 2000, gamer reaction '1'
        else:
            gamerReaction=1
        sleep(0.01)
    #buzzer working
    buzzer.duty_u16(2000)
    sleep(0.05)
    buzzer.duty_u16(0)
    if gamerReaction==nightorday:
        score += 10
    #when score is 10, OLED says 'Game Over'
    else:
        oled.fill(0)
        oled.show()
        oled.text("Game Over", 0, 18, 1)
        oled.text("Your score " + str(score), 0,35)
        oled.text("Press RESET",0, 45)
        oled.text("To REPEAT",0,55)
        oled.show()
        buzzer.duty_u16(2000)
        sleep(0.05)
        buzzer.duty_u16(0)
        break;
    if score==100:
        #when score is 10, OLED says 'You Won'
        oled.fill(0)
        oled.show()
        oled.text("Congratulation", 10, 10)
        oled.text("Top Score: 100", 5, 35)
        oled.text("Press Reset", 20, 45)
        oled.text("To REPEAT", 25,55)
        oled.show()
        buzzer.duty_u16(2000)
        sleep(0.1)
        buzzer.duty_u16(0)
        sleep(0.1)
        buzzer.duty_u16(2000)
        sleep(0.1)
        buzzer.duty_u16(0)
        break;
				
			

Arduino C Codes of the PicoBricks

				
					#include <Wire.h>
#include "ACROBOTIC_SSD1306.h"
//define the library


#define RANDOM_SEED_PIN     28
int Gamer_Reaction=0;
int Night_or_Day=0;
int Score=0;
int counter=0;

double currentTime=0;
double lastTime=0;
double getLastTime(){
  return currentTime=millis()/1000.0-lastTime;
}

void _delay(float seconds){
  long endTime=millis()+seconds*1000;
  while (millis()<endTime) _loop();
}

void _loop(){
}

void loop(){
  _loop();
}
//define variable

void setup() {
  // put your setup code here, to run once:
  pinMode(10,INPUT);
  pinMode(27, INPUT);
  pinMode(20,OUTPUT);
  randomSeed(RANDOM_SEED_PIN);
  Wire.begin();
  oled.init();
  oled.clearDisplay();
  //define the input and output pins

  oled.clearDisplay();
  oled.setTextXY(1,3);
  oled.putString("NIGHT and DAY");
  oled.setTextXY(2,7);
  oled.putString("GAME");
  oled.setTextXY(5,2);
  oled.putString("Press the BUTTON");
  oled.setTextXY(6,4);
  oled.putString("to START!");
  //write "NIGHT an DAY, GAME, Press the BUTTON, to START" on the x and y coordinates determined on the OLED screen

  Score=0;
  //define the score variable

  while(!(digitalRead(10)==1))  //until the button is pressed
  {
    _loop();
  }
  _delay(0.2);

  while(1){  //while loop
    if(counter==0){
      delay(500);
      Change_Word();
      lastTime=millis()/1000.0;
    }
    while(!(getLastTime()>2)){
      Serial.println(analogRead(27));
      if(analogRead(27)>200){
        Gamer_Reaction=0;

      }
      else{
        Gamer_Reaction=1;
      }
    }
   //determine the gamer reaction based on the value of the LDR sensor
   digitalWrite(20,HIGH);   //turn on the buzzer
   delay(250);  //wait
   digitalWrite(20,LOW);  //turn off the buzzer

   if(Night_or_Day==Gamer_Reaction){  //if the user's reaction and the Night_or_Day variable are the same
    Correct();
   
   }
   else{
    Wrong();
   }
   _loop();

   if(Score==100){
      oled.clearDisplay();
      oled.setTextXY(1,1);
      oled.putString("Congratulation");
      oled.setTextXY(3,1);
      oled.putString("Your Score");
      oled.setTextXY(3,13);
      String String_Score=String(Score);
      oled.putString(String_Score);
      oled.setTextXY(5,3);
      oled.putString("Press Reset");
      oled.setTextXY(6,3);
      oled.putString("To Repeat!");
      //write the "Congratulation, Your Score, press Reset, To Repeat!" and score variable on the x and y coordinates determined on the OLED screen
      for(int i=0;i<3;i++){
        digitalWrite(20,HIGH);
        delay(500);
        digitalWrite(20,LOW);
        delay(500);
     
    }
    //turn the buzzer on and off three times
    counter=1;

   }
  }
}

void Correct(){
  Score+=10;
  oled.clearDisplay();
  oled.setTextXY(3,4);
  oled.putString("10 Points");
  //increase the score by 10 when the gamer answers correctly
}

void Change_Word(){
  
  oled.clearDisplay();
  Night_or_Day=random(0,2);
  if(Night_or_Day==0){
    oled.setTextXY(3,6);
    oled.putString("NIGHT");

  }
  else{
    oled.setTextXY(3,7);
    oled.putString("DAY");
  }
 
}
//write "NIGHT" or "DAY" on random OLED screen

void Wrong(){
  oled.clearDisplay();
  oled.setTextXY(1,3);
  oled.putString("Game Over");
  oled.setTextXY(3,1);
  oled.putString("Your Score");
  oled.setTextXY(1,13);
  String String_Score=String(Score);
  oled.putString(String_Score);
  oled.setTextXY(5,3);
  oled.putString("Pres Reset");
  oled.setTextXY(6,3);
  oled.putString("To Repeat");
  // write the score variable and the expressions is quotation marks to the coordinates determined on the OLED screen.

  digitalWrite(20,HIGH);  //turn on the buzzer
  delay(1000);   //wait
  digitalWrite(20,LOW); //turn off the buzzer
  counter=1;
}
				
			

Project Image

Project Proposal 💡

You can modify the project based on the LDR sensor values, and automatically determine the limit via calibration of the sensor in code. You can add a difficulty level to the game. The difficulty level can be selected with the potentiometer as easy, medium and hard. The change time for words can be 2 seconds for Easy, 1.5 seconds for Medium, and 1 second for Hard.

14 dinosaur game project with picobricksCategoriesLed Raspberry Pi Pico Uncategorized

#14 Dinosaur Game Project with PicoBricks

If the electronic systems to be developed will fulfill their duties by pushing, pulling, turning, lifting, lowering, etc., pneumatic systems or electric motor systems are used as actuators in the project. PicoBricks supports two different motor types: DC motors and Servo motors. Servo motors are DC motors whose movements are regulated electronically. Servo motors are motors that can rotate to an angle. In RC vehicles, servo motors are used with the same logic to control the steering and change the direction of the vehicle. In addition, advanced servo motors known as smart continuous servos, which can rotate 360 deg, are also used in the wheels of the smart vacuum cleaners we use in our homes.

In this project you will learn how to control Servo motors with PicoBricks.

Details and Algorithm

In this project, we will automatically play Google Chrome offline dinosaur game with PicoBricks. In the game, PicoBricks will automatically control the dinosaur’s movements by detecting obstacles. We will use the PicoBricks LDR sensor to detect the obstacles in front of the dinosaur. LDR can send analog signals by measuring the amount of light touching the sensor surface. By fixing the sensor on the computer screen and monitoring the difference in the amount of light between the white and black colors, we can detect if there is an obstacle in front of the dinosaur. When an obstacle is detected, we can use a servo motor to automatically press the spacebar on the keyboard and make the dinosaur overcome the obstacles. We will attach the LDR sensor to the computer screen and read the sensor data on the white and black background. Then, based on the data, we write the necessary code for the servo motor to move.

Components

1X PicoBricks
1X Servo Motor
3X Easy Connection Cables

Wiring Diagram

Note: PicoBricks motor control module is used to control both DC and SERVO motors. The selection is done with a 3-pin jumper block. The end pins of the jumper block are marked with DC MOTOR and SERVO. Place the jumper to match the type of motor you are using in your project – SERVO in our case.

You can code and run Picobricks modules without wiring. If you are going to use the modules by separating them from the board, you should make the module connections with grove cables.

MicroBlocks Codes of the PicoBricks

204212948 5c168792 f88f 49ff 8608 3f9e9bf0cb9e

You can access the Microblocks codes of the project by dragging the image to the Microblocks Run tab or click the button.

MicroPython Codes of the PicoBricks

				
					from machine import Pin, ADC, PWM#to access the hardware on the pico
from utime import sleep #time library

ldr=ADC(27) #initialize digital pin 27 for LDR
servo=PWM(Pin(21)) #initialize digital PWM pin 27 for Servo Motor
servo.freq(50)

while True:
    sleep(0.01)
    #When LDR data higher than 40000
    if ldr.read_u16()>4000:
        servo.duty_u16(2000)# sets position to 180 degrees
        sleep(0.1)#delay
        servo.duty_u16(1350) # sets position to 0 degrees
        sleep(0.5)#delay
				
			

Arduino C Codes of the PicoBricks

				
					#include <Servo.h>
Servo myservo;

void setup() {
  // put your setup code here, to run once:
  myservo.attach(22);
  myservo.write(20);
  pinMode(27,INPUT);

  

}

void loop() {
  // put your main code here, to run repeatedly:
  int light_sensor=analogRead(27);

  if(light_sensor>100){

    int x=45;
    int y=20;
    
    myservo.write(x);
    delay(100);
    myservo.write(y);
    delay(500);
  }


}
				
			

Project Image

Project Proposal 💡

At first in the game, the ground color is white and the figures are black. After a certain stage, the colors are reversed. For this reason, LDR sensor data changes. To solve this problem, you can use variables and functions to run one code group when the game is on a white background, another code group when it is on a black background, or you can install a second LDR sensor to detect this difference.

PicoBricks and its modules allow us to develop many projects from simple to complex, that we can use in different games such as minecraft.