Week 28. Mar 11.15 2019 - michelle-qin/Portfolio GitHub Wiki

The first 2 days of this week I focused on documenting the snake pendulum code. As I was working with a mentor (who was previously unfamiliar with the project) last week, I began to notice several areas that were unclear in the code due to confusing variable names and lack of documentation and comments. So, I spent time carefully doing that so that future students would be able to better understand the code if they were to go through it. I pushed the code to github and the DPEA repo currently has the most updated version of the code.

After that, I focused on working on the rotating part for the Ball Wall. I first looked at an example titled "Servo" to understand how to program the part using adafruit's featherwing. After studying that example file for a bit, I took a look at adafruit's documentation (https://learn.adafruit.com/16-channel-pwm-servo-driver/library-reference) and learned a lot more about the library references from there.

Once I got a better basis, I started a new file to program the part myself. I was successful for the 1st "prototype." My code is below.

//TEST by Michelle//

#include <Wire.h> #include <Adafruit_PWMServoDriver.h>

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

bool sensor_passed = true;

void setup() { // put your setup code here, to run once: Serial.begin(9600); Serial.println("Hello"); pwm.begin(); pwm.setPWMFreq(1000); }

void loop() { // put your main code here, to run repeatedly: int sensor_outside = digitalRead(5); int sensor_inside = digitalRead(6);

if (sensor_inside == 1) { //no metal pwm.setPWM(0, 1024, 3072); } else { if (sensor_outside == 0) { // 0 = metal updateSensorReading(); } else { pwm.setPWM(0, 0, 4096); delay(500); } } }

void updateSensorReading() { sensor_passed = true; for (int i = 0; i < 3000; i++) { Serial.println(i); pwm.setPWM(0, 1024, 3072); } pwm.setPWM(0, 0, 4096); sensor_passed = false; delay(5000); }

However, this first prototype was not continuous --- it had a break in between its cycle. I'm currently fixing that so it runs in a continuous, smooth cycle. That is my goal for this coming week.

⚠️ **GitHub.com Fallback** ⚠️