To begin with, we were provided with a piece of code to upload to the Arduino that could constantly write and read to the serial port...
#includeWe then uploaded the code to the Arduino. Initially, the board was not responding to the commands being sent to it. But after some tweaking of the COM ports, it was sending signals. After we got the Arduino successfully broadcasting we connected a potentiometer to it in a simple circuit, as shown below...
void setup()
{
// The following command initiates the serial port at 9600 baud. Please note this is VERY SLOW!!!!!!
// I suggest you use higher speeds in your own code. You can go up to 115200 with the USB version, that's 12x faster
Serial.begin(9600); //Baud set at 9600 for compatibility, CHANGE!
}
void loop()
{
if (messageBuild() > 0) { // Checks to see if the message is complete and erases any previous messages
switch (messageGetChar()) { // Gets the first word as a character
case 'r': // Read pins (analog or digital)
readpins(); // Call the readpins function
break; // Break from the switch
case 'w': // Write pin
writepin(); // Call the writepin function
}
}
}
void readpins(){ // Read pins (analog or digital)
switch (messageGetChar()) { // Gets the next word as a character
case 'd': // READ digital pins
messageSendChar('d'); // Echo what is being read
for (char i=2;i<14;i++) i="0;i<6;i++)" pin =" messageGetInt();" state =" messageGetInt();" pin =" messageGetInt();" state =" messageGetInt();">
We were then introduced to the new application that would be using the serial signal from the Arduino, Max/MSP. Max/MSP is a MIDI/Audio/Video processing program that we will use to produce a square wave according to parameters set by the serial output from the Arduino.Max/MSP is a visal/object orientated programming environment we will use in real time to produce the square wave. The setup we used from the example (and then adapted to then output to the motherboard speaker) looked like this:
Here is a video of the setup running...
After conducting this exercise I think I should start brainstorming ideas for a larger more useful circuits. A good way to start this would be to sketch very basic diagrams of their circuits.
No comments:
Post a Comment