Uncategorized Archives - Botmation's personal blog for creating robots and ai https://botmation.net/category/uncategorized/ Botmation's Blog Sat, 04 Mar 2023 18:55:47 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.3 My New Assistant ChatGPT https://botmation.net/2023/03/04/my-new-assistant-chatgpt/ https://botmation.net/2023/03/04/my-new-assistant-chatgpt/#respond Sat, 04 Mar 2023 18:51:54 +0000 https://botmation.net/?p=329 I have been playing around with ChatGPT for a while now. Playing around with different prompts and example I have seen on the web. One thing that it does great compare to the existing assitants suchs as Alexa or Google Continue reading My New Assistant ChatGPT

The post My New Assistant ChatGPT appeared first on Botmation's personal blog for creating robots and ai.

]]>
I have been playing around with ChatGPT for a while now. Playing around with different prompts and example I have seen on the web. One thing that it does great compare to the existing assitants suchs as Alexa or Google is the conversational flow. This assistant really feels like you are talking to someone.

From this flow we can use ChatGPT as a low cost instructor for simple applications. 

I found it great for generating ideas or variations of topics. I would ask it for project ideas. Then do a follow up question to elaborate on the topic you are interested in. 

Lets ask ChatGPT to give me raspberry PI project ideas.

Can you generate raspberry pi project ideas using LED lights?

ChatGPT reponse

Sure, here are some Raspberry Pi project ideas using LED lights:

1 LED Traffic Light Simulator: Build a traffic light simulator using LEDs and the Raspberry Pi. This project can help you learn about programming GPIO pins and timing with Python. You can also add a button to simulate a pedestrian crossing button.

2 LED Matrix Display: Create an LED matrix display using Raspberry Pi and LED strips. You can display scrolling text, animations, and even create a game using the LED matrix display.

3 LED Mood Lamp: Build an LED mood lamp that changes colors based on ambient light or sound. You can use a microphone sensor to detect sound levels and change the LED color accordingly.

4 LED Cube: Create a 3D LED cube that displays various patterns and animations. This project can help you learn about programming 3D animations and graphics.

5 LED Music Visualizer: Build a music visualizer using LED lights and Raspberry Pi. This project can help you learn about audio processing and frequency analysis.

6 LED Night Light: Create a LED night light that turns on automatically in the dark using a light sensor. You can also add a button to change the color of the LED.

7 LED Clock: Build an LED clock that displays the time using LED lights. You can also add temperature and humidity sensors to display additional information.

8 LED Temperature Display: Create an LED temperature display that shows the current temperature using different colors. This project can help you learn about programming temperature sensors and using LED lights to display information.

9 LED Christmas Tree: Build an LED Christmas tree that can be controlled using Raspberry Pi. You can create various lighting patterns and even add music to the tree.

10 LED Aquarium Lighting: Create an LED lighting system for your aquarium using Raspberry Pi. You can program different lighting cycles and colors to simulate different times of the day and help your fish thrive.

Can you provide example code for item 5?

Sure, here's an example Python code for a simple LED music visualizer using a Raspberry Pi and an LED strip:

import alsaaudio as aa
import audioop
import time
from neopixel import *

# LED strip configuration
LED_COUNT = 60       # Number of LED pixels
LED_PIN = 18         # GPIO pin connected to the pixels
LED_FREQ_HZ = 800000 # LED signal frequency in hertz
LED_DMA = 10         # DMA channel to use for generating signal
LED_BRIGHTNESS = 255 # Set to 0 for darkest and 255 for brightest
LED_INVERT = False   # True to invert the signal (when using NPN transistor level shift)

# Create LED strip object
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS)
strip.begin()

# Initialize audio input
input = aa.PCM(aa.PCM_CAPTURE, aa.PCM_NONBLOCK, 'hw:1')
input.setchannels(1)
input.setrate(44100)
input.setformat(aa.PCM_FORMAT_S16_LE)
input.setperiodsize(1024)

# Define color gradient for visualizer
colors = [(0, 0, 255), (0, 255, 0), (255, 255, 0), (255, 0, 0)]

# Define function to set LED colors based on sound level
def set_leds(level):
    # Calculate color index based on sound level
    color_index = int(level / 16384.0 * len(colors))
    if color_index >= len(colors):
        color_index = len(colors) - 1
    # Set LED colors
    for i in range(LED_COUNT):
        color = colors[color_index]
        strip.setPixelColor(i, Color(color[1], color[0], color[2]))
    strip.show()

# Main loop
while True:
    # Read audio data from input
    l, data = input.read()
    if l:
        # Calculate sound level
        level = audioop.max(data, 2)
        # Set LED colors based on sound level
        set_leds(level)
    # Sleep for a short time
    time.sleep(0.01)

Can you add a function to the code to change LED colors to all blue for 4 seconds?

Sure, here's an updated version of the code that adds a change_color() function to change the LED colors to all blue for 4 seconds:

import alsaaudio as aa
import audioop
import time
from neopixel import *

# LED strip configuration
LED_COUNT = 60       # Number of LED pixels
LED_PIN = 18         # GPIO pin connected to the pixels
LED_FREQ_HZ = 800000 # LED signal frequency in hertz
LED_DMA = 10         # DMA channel to use for generating signal
LED_BRIGHTNESS = 255 # Set to 0 for darkest and 255 for brightest
LED_INVERT = False   # True to invert the signal (when using NPN transistor level shift)

# Create LED strip object
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS)
strip.begin()

# Initialize audio input
input = aa.PCM(aa.PCM_CAPTURE, aa.PCM_NONBLOCK, 'hw:1')
input.setchannels(1)
input.setrate(44100)
input.setformat(aa.PCM_FORMAT_S16_LE)
input.setperiodsize(1024)

# Define color gradient for visualizer
colors = [(0, 0, 255), (0, 255, 0), (255, 255, 0), (255, 0, 0)]

# Define function to set LED colors based on sound level
def set_leds(level):
    # Calculate color index based on sound level
    color_index = int(level / 16384.0 * len(colors))
    if color_index >= len(colors):
        color_index = len(colors) - 1
    # Set LED colors
    for i in range(LED_COUNT):
        color = colors[color_index]
        strip.setPixelColor(i, Color(color[1], color[0], color[2]))
    strip.show()

# Define function to change LED colors to all blue for 4 seconds
def change_color():
    for i in range(LED_COUNT):
        strip.setPixelColor(i, Color(0, 0, 255))
    strip.show()
    time.sleep(4)
    set_leds(0)

# Main loop
while True:
    # Read audio data from input
    l, data = input.read()
    if l:
        # Calculate sound level
        level = audioop.max(data, 2)
        # Set LED colors based on sound level
        set_leds(level)
    else:
        # Change LED colors to all blue for 4 seconds
        change_color()
    # Sleep for a short time
    time.sleep(0.01)

Which GPIO pins do I need to wire the LED?

In the code I provided earlier, the LED strip is connected to GPIO pin 18. However, the specific GPIO pins you will need to wire the LED will depend on the type of LED you are using and how you have it wired.

If you are using a single LED, you will typically need to connect one leg of the LED to a GPIO pin and the other leg to a ground pin. The GPIO pin you use will depend on which GPIO pins are available on your Raspberry Pi and which ones you have available to use.

If you are using an LED strip, you will typically need to connect the data input pin of the LED strip to a GPIO pin on the Raspberry Pi, and also connect the LED strip's power and ground pins to a power source and ground pin, respectively.

You should refer to the documentation or specifications for your specific LED or LED strip to determine which pins you need to connect to your Raspberry Pi. Additionally, it's important to make sure you use the appropriate voltage and current to power your LED, as exceeding the limits can damage the LED or your Raspberry Pi.

My Thoughts and take aways

Just from a quick conversation with chatGPT I was able to generate ideas I can pick from. Then I was able to have it provide me a quick template for me to jump right to it.

I even ask where to wire a LED and it remembers which GPIO pin I needed to connect to. This helps me out a lot when I am busy doing many things everyday. When I do find time to do a bit of fun, I like to just jump right into it. ChatGPT has shown it can help me run out of the gate.

I hope you all enjoyed my quick demo and feel the excitement for this new technology as much as I do.

Tips to generate ideas with ChatGPT

  • What are some cool projects I can do with raspberry pi and a camera?
  • How can I use raspberry pi to control a robot arm?
  • How do I program mqtt client and server?

Phrase your question in a clear and specific way. ChatGPT will try to answer your question by generating a paragraph of text that describes one or more possible project ideas. You can also ask follow-up questions to get more details or clarification from ChatGPT.

  • Can you tell me more about mqtt client?
  • Can you add a LED variable to the mqtt server?
  • Generate more ideas from the second bullet.

The post My New Assistant ChatGPT appeared first on Botmation's personal blog for creating robots and ai.

]]>
https://botmation.net/2023/03/04/my-new-assistant-chatgpt/feed/ 0 329
Making a Humanoid Robot Part 1 https://botmation.net/2020/01/28/making-a-humanoid-robot-part-1/ https://botmation.net/2020/01/28/making-a-humanoid-robot-part-1/#respond Tue, 28 Jan 2020 03:39:56 +0000 http://www.botmation.net/?p=76 Back Story Hello, After the long holiday session I am finally back on track to start my next project. I think it’s about time I try tackling humanoid robot making. I been bouncing ideas with my kid. He originally wanted Continue reading Making a Humanoid Robot Part 1

The post Making a Humanoid Robot Part 1 appeared first on Botmation's personal blog for creating robots and ai.

]]>
Back Story

Hello,

After the long holiday session I am finally back on track to start my next project. I think it’s about time I try tackling humanoid robot making. I been bouncing ideas with my kid. He originally wanted a robot dog which can play, talk, and clean up his toys. After a few weeks designing out the details then he comes back with, let’s make a transformer robot. I of course said well that sounds even more awesome than the last!


I was reading up the latest from CES this year and came upon a kick starter company that made just that. The robot is called T9 by Robosen and it was originally suppose to be Optimus Prime, but I assume they didn’t want to pay royalties to Hasbro and ended up with a generic truck look. However, the functions are still there. After seeing this I starting going down the youtube rabbit hole and ended up watching humanoid robot competitions.

This is when I learned that we have come a long way from the early walking robots. I have never built a humanoid robot before, but after seeing how so many people built really agile robots I am inspired to try it for myself.
Having my own humanoid robot is one of my dreams. All sorts of ideas is flowing through my mind. I can make the robot talk, walk around the house, maybe clean up toys, and put away the groceries.
Of course all that will take a lot of time and development. Which I do not have too much of with a working full time and raising a kid. So I plan to make this a long series, but great mini stories as I go along.

Planning

To build a humanoid robot from scratch requires a ton of up front planning and research. Some things I ask myself are:

How big is this robot?
What kind of parts do I need?
How much are the parts?

How are the joints connected?
How am I going to program it?
What are the features I need it to function?
Are there a pre-made kits or instructions?
What are the current techniques for training the robot?
How do I make the robot walk?

First I looked for existing works with guides to jump start my project. I found one project with some details of how it was built. This build had 17 servos controlling multiple joints. Each servo contributes to what is referred as degree of freedom (DOF) for short. The robot also had two other key components, a gyroscope accelerometer and servo driver. The gyroscope and accelerometer will give the robot a sense of balance and force. The server driver allows multiple servos be controlled from a single interface to something like a raspberry pi.

My next steps which I will talk about in the next post, will be the design of the robot. Such as where are my joints going to be and what kind of frame will I use to put all the servos together.

The post Making a Humanoid Robot Part 1 appeared first on Botmation's personal blog for creating robots and ai.

]]>
https://botmation.net/2020/01/28/making-a-humanoid-robot-part-1/feed/ 0 76