Show Posts
|
|
Pages: [1]
|
|
1
|
Using Arduino / Interfacing w/ Software on the Computer / Re: Controlling Arduino with Processing GUI
|
on: December 31, 2012, 01:37:34 pm
|
Thanks for the help, I understand what you are suggesting, and I think it will work quite well, but I am having trouble figuring out how to get the Arduino to read the commands from the serial port in the format that you suggested. I know that I will have to read the data into some kind of variable, then determine what the data is and what needs to be done, but I am not sure what code to use to do this. In the past, I have done very basic serial control where I used code like this: void loop() { // see if there's incoming serial data: if (Serial.available() > 0) { incomingByte = Serial.read(); // read the oldest byte in the serial buffer
//Preform the code to activate the stepper motor and the LEDs
if (incomingByte == '0') { myStepper.step(14); // moves the stepper 14 steps forward delay(50); // wait 50ms myStepper.step(-14); // moves the stepper 14 steps backward
Also, what would be a simple way to convert an angle into a set number of steps? Thanks again for all of the help.
|
|
|
|
|
2
|
Using Arduino / Interfacing w/ Software on the Computer / Controlling Arduino with Processing GUI
|
on: December 30, 2012, 06:32:15 pm
|
|
Hi, I am working on a project for school that involves making a spring powered launcher that has to fire a projectile a set distance by adjusting the angle and amount of tension in the spring. I would like to make it so that I can enter a distance into a processing program on the computer, and have it automatically calculate the required angle and tension for the spring (using a pre-made equation). I would like it to then send this data to the Arduino via USB and have it move the motors to the correct location. Finally, I would like to have a button (either real or virtual) that will fire the projectile by activating a solenoid. I already know how to interface stepper motors and solenoids to the Arduino, but I need some help with how to approach the computer side of the project.
Any help would be greatly appreciated.
Thanks!
|
|
|
|
|
3
|
Using Arduino / Interfacing w/ Software on the Computer / Re: Controlling Arduino with PHP over serial...
|
on: January 04, 2012, 05:30:22 pm
|
Do you have PHP installed, configured, and known to be working?
Have you found and installed the PHP serial class?
What operating system are you using?
There are plenty of examples on the PHP site (php.org). PHP is a lot like C, so it isn't that hard to get a PHP script to send serial data, once you have the PHP serial class installed.
Hi, I have PHP installed and working using MAMP Server on my Mac. I have a the php_seroal.class.php file, but I did not know that I had to install it. How do you install a php class? I googled it, but could not find any information... Thanks for all of the help.
|
|
|
|
|
4
|
Using Arduino / Interfacing w/ Software on the Computer / Controlling Arduino with PHP over serial...
|
on: January 04, 2012, 04:50:29 pm
|
Hello, I am trying to make a ping pong ball launcher. I need a controller that allows me to move a stepper motor to three preset positions when I click a button on a webpage. I have made the Arduino code and circuit, and it works in that it responds when I send commands through the serial monitor. Here is my current Arduino Code: #include <Stepper.h>
int ledPin13 = 13; // the pin that the main LED is attached to int incomingByte; // a variable to read incoming serial data into Stepper myStepper(48, 9,10,11,12); //Set up 48 step stepper motor using pins 9,10,11,12 void setup() { Serial.begin(9600); // initialize serial communication pinMode(ledPin13, OUTPUT); // initialize the green LED pin as an output myStepper.setSpeed(60); // 60 rpms } void loop() { digitalWrite(ledPin13, HIGH); //Turn on the main LED // see if there's incoming serial data: if (Serial.available() > 0) { incomingByte = Serial.read(); // read the oldest byte in the serial buffer
//Preform the code to switch on or off the leds
if (incomingByte == '0') { myStepper.step(14); // moves the stepper 14 steps forward delay(300); // wait half a second. myStepper.step(-14); // moves the stepper 14 steps backward } if (incomingByte == '1') { myStepper.step(7); // moves the stepper 7 steps forward } if (incomingByte == '2') { myStepper.step(-7); // moves the stepper 7 steps backward }
} }
I need a webpage that has three buttons. One that says "Fire" and sends the value "0" through serial, one that says "Rapid Fire On" and sends the value "1" through serial, and one that says "Rapid Fire Off" and sends the value "2" through serial. Does anyone know how I should go about this? I am familiar with HTML, but not PHP. Thanks, Andrew
|
|
|
|
|
5
|
Using Arduino / Audio / Arduino MIDI Controller
|
on: November 27, 2011, 05:04:37 pm
|
Hello, I am trying to build a midi controller with an Arduino. I would like to have 16 buttons that triggered a midi event when they were pushed. I would also like to have the buttons lit with an white LED all of the time, then change to blue when they are pushed. I know that I will need to use shift registers, such as the CD4021BE, for the buttons, and another set of shift registers, such as the 74HC595 to control the leds. I have read the ShiftIn and ShiftOut tutorials: http://www.arduino.cc/en/Tutorial/ShiftIn and http://arduino.cc/en/Tutorial/ShiftOut, as well as how to interface with MIDI - http://arduino.cc/en/Tutorial/MidiI have a basic understanding of how each system would work, and how to wire them up, but I have no idea how to write a program that would combine all of them into a finished product. Thanks for the help.
|
|
|
|
|
7
|
Using Arduino / Audio / Re: Arduino Drum Machine
|
on: September 14, 2011, 03:58:08 pm
|
When you install the MIDI library you will also get some examples (found in the File menu Examples submenu in the Arduino SDK), like you get for most libraries you install. But if the only MIDI you need is to send note on, you can do without the MIDI library. Or if you just want some understanding of how things work it could be a good idea to fix your code before changing to the library. I don't have time to test (I mean, I have to leave some fun for you!) but something like this should fix your note on function: void noteOn(byte channel, byte key, byte velocity) { Serial.print(0x90 & channel, BYTE); Serial.print(key, BYTE); Serial.print(velocity, BYTE); }
And if you thought 10 was the MIDI channel to use for drums, you need to change that to 9. Channels are numbered 1 to 16, but go from 0 to 15 in the protocol. Thanks for all the help, I tried your new code, but I am still getting "invalid" MIDI signals. Here is my code again: int ledPin = 13 ; // Led connected to digital pin 13 int piezo1 = 0 ; // Piezo 1 connected to analog 0 byte val = 0 ; // variable to store the value read from the sensor pin int statePin = 0; // variable used to store the last LED status , to toglle the light byte THRESHOLD = 60; // threshold value to decide when the detected sound is a knock or not
void setup() { pinMode(ledPin, OUTPUT); // declare the ledPin as OUTPUT Serial.begin(31250); // set MIDI baud rate }
void loop(){ // deal with first piezo val = analogRead(piezo1)/4; if (val >= THRESHOLD) { noteOn (9 , 144, 100); digitalWrite(ledPin, HIGH); delay(1); digitalWrite(ledPin, LOW); } }
// plays a MIDInote doesn't check to see that cmd is greater than 127 or that data values are less than 127 void noteOn(byte channel, byte key, byte velocity) { Serial.print(0x90 & channel, BYTE); Serial.print(key, BYTE); Serial.print(velocity, BYTE); } Thanks again for the help.
|
|
|
|
|
8
|
Using Arduino / Audio / Re: Arduino Drum Machine
|
on: September 12, 2011, 07:54:26 pm
|
I'd suggest using the MIDI library, it's much easier to use.
As to the invalid message problem, does the program actually listen for serial messages? Because MIDI over USB is a totally different protocol (because it has to obey usb protocol) than sending MIDI directly thru a virtual serial port. There's a serial-to-MIDI converter application available on the intarwebs, just do a google search.
As to hardware, are you looking into having velocity sensitivity? If not, then the piezos could be wired as digital sensors, and have a trimmer pot to adjust the sensitivity.
Thanks for the quick reply, I am using a usb to MIDI cable to connect it to my computer. I don't really care about having the pads velocity sensitive, but I am not sure how I would wire them to the Arduino as digital sensors. I am relatively new to Arduino, and am hoping that this project will help me learn more about the Arduino. Do you happen to know where I might find some sample code to use the MIDI library? Thanks again for your help
|
|
|
|
|
9
|
Using Arduino / Audio / Arduino Drum Machine
|
on: September 12, 2011, 06:26:56 pm
|
Hello, I am working on building a very large drum machine. I would like to have 16 pads that are lit with one color all of the time, but change to another color when they are struck. I also need each pad to send a MIDI signal when they are hit. I am going to use piezos as sensors because they are cheap and seem to work quite well. I have started by hooking up one piezo sensor and a midi out port to the Arduino using the schematic I found here: http://todbot.com/blog/wp-content/uploads/2006/10/arduino_midi_schematic.png . I have managed to get an LED to flash when the piezo is hit, but I am having trouble getting a MIDI signal. I used the program "MIDI Monitor" on my mac to read what MIDI data was coming in, and it kept saying that the commands were "invalid". Here is the code that I am using: int ledPin = 13 ; // Led connected to digital pin 13 int piezo1 = 0 ; // Piezo 1 connected to analog 0 byte val = 0 ; // variable to store the value read from the sensor pin int statePin = 0; // variable used to store the last LED status , to toglle the light byte THRESHOLD = 100; // threshold value to decide when the detected sound is a knock or not
void setup() { pinMode(ledPin, OUTPUT); // declare the ledPin as OUTPUT Serial.begin(31250); // set MIDI baud rate }
void loop(){ // deal with first piezo val = analogRead(piezo1)/4; if (val >= THRESHOLD) { noteOn (144 , 10, 100); digitalWrite(ledPin, HIGH); delay(1); digitalWrite(ledPin, LOW); } }
// plays a MIDInote doesn't check to see that cmd is greater than 127 or that data values are less than 127 void noteOn(char cmd, char data1,char data2) { Serial.print(cmd, BYTE); Serial.print(data1, BYTE); Serial.print(data2, BYTE); } I got this code from another forum thread ( http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1197975890) What I am wondering is how I can fix my MIDI issue, how I can make it so that the pads are one color until they are hit, in which case they will turn another color and back again, and how I can hook up 16 pads to the 6 inputs on the Arduino. I know that I will need to use a multiplexer for the inputs, and probably one for the outputs too (I need to use 32 separate LEDs). I would like to use something like a 74HC4051, as they are readily available at my local electronics store. Thank you very much for your help.
|
|
|
|
|
10
|
Using Arduino / Audio / Re: Music Syncronized MIDI controller.
|
on: February 10, 2011, 04:47:11 pm
|
|
Is there anyway to make it so that when you push a button, it sends a preset note through a MIDI interface? Could I not then just modify a simple LED UV meter to trigger the arduino's inputs?
Thanks again for all of the help.
|
|
|
|
|
11
|
Using Arduino / Audio / Music Syncronized MIDI controller.
|
on: February 08, 2011, 10:09:28 pm
|
Hello, I was wondering if you could help me with a project. Our school has a lighting system that can be controlled by midi signals through a program called MyDMX. Usually, we hook up an electronic drum kit to sync our light shows to music. This works great for live bands, but whenever we have to play music from an iPod, we have to rely on the built in effect (ok, but not music synchronized). What I would like to do is build a device that would listen to the music using a microphone and output MIDI signals according to the music it hears. I have some experience in syncing lights to music using an arduino (see my Music Synchronized Traffic Light on my website at http://colvins.ca). What I do not know how to do is make it use a microphone and operate independently from a computer. Also, I do not know what I need to make it output to midi instead of LEDs. Does anyone know how I could do this? Thanks!
|
|
|
|
|