Skip to content

gventre04/CircuitPython

Repository files navigation

Circuit Python

My CircuitPython assignments:

Table of Contents

LED Fade

LED Fade Code

Objective

This assignment required us to initially learn to manipulate the on board RGB LED and to make the LED blink. Once we had figured out how to make the LED blink we had to make code for an LED so that it would fade in and out gradually.

Wiring Diagram

Lesson(s) Learned

This assignment served as our introduction into the new language of CircuitPython and a new board called a Metro MO Express. This coding langauge requres many different imports such as math, time, board, digitalio, neopixel to name a few. This specific assignment I learned how to use the import pulseio which is required to make the LED fade as well as manipulating the duty cycle. This website helped me better understand how to use PWM.

Servo Capacitative Touch

Servo Capacitative Touch Code

Objective

This code uses two wires inserted into Analog pins to control the direction of a servo, touching one spins it clockwise, and the other spins it counterclockwise. The servo would only move when the wires were touched.

Wiring Diagram

Link to Abby Paquette's Original Image

Lesson(s) Learned

The concept of capacitative touch was completely new to me so I had to rely on google and Mr. H for guidance. We also were required to download our first module, adafruit motor, onto the Metro. I initially had trouble getting the movement of the servo to be slight rather than a complete 180 degree turn per touch, but after using if statements I managed to regulate the movement of the servo.

CircuitPython LCD

CircuitPython LCD Code

Objective

This code uses a button and an lcd screen, and a switch, when pushing the button, a counter on the lcd screen increase by +1. Flipping the switch will decrease the counter on the screen by -1.

Wiring Diagram

Link to Abby Paquette's Original Image

Lesson(s) Learned

I had a problem with the button being held causing the button counter on the LCD to continuosly counting up or down. I had to add oldButtonState to make sure each press counted for a single +1 on the LCD. This website helped me understand how to set-up a button and switch in circuit python, along with example code showing how it's done.

Photo Interrupter

Photo Interrupter Code

Objective

This code counts the amount of time the photointerrupter has been interrupted within a given interval, posting that number on the serial monitor every 4 seconds.

Wiring Diagram

Link to Abby Paquette's Original Image

Lesson(s) Learned

The challenging part about this assignment was the time interval and including the amount of interrupts in that given interval. I solved with with photo and state to count the interrupts and start = time.time() to calculate the 4 second interval. This website explains how to use the import time module, specifically time.time().

Distance Sensor

Distance Sensor Code

Objective

This assignment had us wire an HCSR-04 sensor and use it as a distance sensor that changes the color of the neopixel on the Metro based on how far an object is from the sensor.

Image

Link to the Original Image

Lesson(s) Learned

The challenge with this assignment was mapping out the parameters for the colors based on distance, initially I coded the sensor to give out three different colors for 5cm, 20cm, and 35cm. This code provides a good example of how to map a sensorValue which then allowed me to add a fade effect on the neopixel as distance from the sensor increased or decreased.

RGB LED

RGB LED Code

Objective

This assignment followed a lesson on classes, objects, and modules and how to use them. The assignment required us to wire two RGB LEDs and create a new library that would allow a code that was premade by the teachers to work. The code would assign different pins to the LEDs and make the LEDS shine different colors at certain times, each RGB LED was given a different color scheme (RBG1-Red, Blue, Magenta RGB2- Green, Cyan, Yellow)

Wiring Diagram

Link to Abby Paquette's Original Image

Lesson(s) Learned

Personally, I found it very difficult to understand how the classes, objects, and modules worked, so this assignment was all around quite difficult. The init function was also quite confusing, especially using it to define r, g, b, the colors themselves weren't too difficult to program. I used this website to better understand how the init function and the self instance worked.

Hello vs Code

Hello vs Code Code

Objective

This assignment was an introduction to Visual Studio (VS) code, which has all the same coding aspects of CircuitPython with the additional built in git. This makes committing, pushing, and pulling information to our GitHubs much easier.

Lesson(s) Learned

Apart from learning the commands of VS Code, this assignment was fairly straight forward. One good thing to remember is to always git push at the end of working on VS Code so all of your work is saved on github, and to git pull when opening VS Code to pull any information/changes made on github, this avoids getting VS Code and github out of sync and potentially losing your work.

Fancy LED

Fancy LED Code

Objective

This assignment had us make yet another library for a pre-made code, this code required us to make six LEDs either alternate, chase, blink, or sparkle.

Wiring Diagram

Link to the Original Image

Lesson(s) Learned

Each seperate command was fairly simple, all you have to do is program the order in which the LEDs turn on and off. I unfortunately stuck my wire into 5V instead of ground, but nothing was fried and the LEDs eventually worked. The Sparkle command was by far the hardest as it required import random I used this website to understand how the random module worked.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages