Now that we have pretty much disassembled the clock, we’re working on rewiring it so each system in the clock functions before reassembly. We had a few problems with publishing this blog due to some unexpected delays(and lack of communication due to traveling/sicknesses) but hope to be able to maintain a more consistent pace over the next few weeks.
Progress summary:
- Finished creation of button + potentiometer interface that will be affixed to the top of the clock
- Got I2C to work with Arduino so we can send and receive messages using a slave
- Implemented time synchronization and random music shuffling (see code below)
Current Goals:
- Modify master so it can be an Edison instead of an Arduino
- Create the foam (or 3-D printed) pieces that will connect the potentiometers to the metal bells
- Redo audio connections
- Implement Edison once it is received
These potentiometers are affixed to tactile buttons, and will be attached to the top of the clock to serve as interfaces. The button caps are removable and we will swap these caps which are connected to the potentiometers with the ones currently on the clock. As mentioned before, these will play a role in controlling audio functions such as volume. Hopefully, we will be able to connect these to the slave Arduino and use I2C communication with the Edison.
As seen below we’ve encountered trouble with our current soldering iron We will have to buy a better one(Weller WLC100WLC100 to complete connections if we plan to use this mic
The master and slave Arduinos running. Although the circuitry is a bit messy, we basically connected the A4/A5 and ground pins for I2C communication and added a potentiometer and button. Currently, we are not very concerned with space, but pending on future designs may be forced to use an arduino nano.
Code:
Slave code:
#include<Wire.h>
void setup() {
Wire.begin(8); // join i2c bus with address #8
Wire.onReceive(receiveEvent); // register event
Serial.begin(9600);
Wire.onRequest(requestEvent);// start serial for output
}
void loop() {
delay(100);
}
// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void requestEvent(){
Wire.write("hello "); /* I couldn’t get it to give a sensor value might have to do with timing? If I replace it with giving the current value for a potentiometer it does work. Might have something to do with button states */
}
void receiveEvent(int howMany) {
while (1 < Wire.available()) { // loop through all but the last
char c = Wire.read(); // receive byte as a character
Serial.print(c);
}
int x = Wire.read(); // receive byte as an integer; checking to make sure the sent value equals original
Serial.println(x); /*May be turned into a stability system, so we say that if two values are more than 5 values apart, we say they aren’t measured(as in the slave sends back the number received and the master sends a new number to check against the first. This is necessary because we noticed the potentiometer values during movement could greatly vary) */
}
Master Code: (Won’t be used as this will be done with an Edison)
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(9600);
}
byte x = 0;
void loop() {
Wire.beginTransmission(8); // transmit to device #8
x=analogRead(2);
Wire.write("x is ");
Wire.write(x);
Wire.endTransmission();
Wire.requestFrom(8, 6); // request 6 bytes from slave device #8
while (Wire.available()) { // slave may send less than requested
char c = Wire.read();
Serial.print(c); // print the character
}
delay(500);
}
Time synchronization / shuffling order of playing music:
timedatectl set-ntp 1
while :; do find ./songs -print0 | shuf -z | xargs -0 -n1 $MUSIC_PLAYER; done
Expected Challenges of Continuation:
Trying to get the errors out of our I2C code will definitely allow us to make the project go more smoothly as most other stuff would be either hardware or simple input/output stuff. Hopefully by next week, we will have the Edison so we can begin figuring that stuff out.
Created by:
Roosh Bhosale
Clyde Johnson
Dhilan Lahoti
Andy Tockman
Joshua Tsai
Ishan Kamat