Skip to content

hgreenh21/CircuitPython-1

 
 

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.

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.

Wiring Diagram

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.

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.

Wiring Diagram

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.

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.

Wiring Diagram

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.

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.

Wiring Diagram

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.

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. I had to add a fade effect from one color to the next as distance increased or decreased.

Image

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)

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 innit function was also quite confusing, especially using it to define r, g, b, the colors themselves weren't too difficult to program.

Wiring Diagram

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.

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.

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 and some research on how the random command works.

Wiring Diagram

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%