I have a small project similar to this viewtopic.php?t=38429
My plan is to write a program which will load a text file to an array in memory and activate an LED based on a certain element’s value in the array, 0 or 1. I will evaluate 120 elements of the array per second.
How do I get the 0’s and 1’s to be significant? That is the fun part! Taking baby steps, first I will use generated values from functions like cosine or even just simply constant functions. I will use this method while working out the hardware side of things. Second I am going to use values generated by a beat tracking program from the MARSYAS project at http://marsyas.info Ultimately my hopes are to create a program that will allow me to ‘compose’ the light based on key presses corresponding to functions that will write into an array the 0’s and 1’s that are later played back with the music.
The conceptual idea I thought up was this: Have FTDI usb cable switch a relay which is on the circuit between a 12v battery and a strip of LEDs.
Im trying to keep as much control in the hands of my program as possible.
So far I have bought this stuff
FTDI TTL-232R-5V … Datasheet : http://www.ftdichip.com/Support/Documen … CABLES.pdf
Breadboard and breadboard wires
Mechanical Relay: DPDT from Radioshack… Datasheet : http://www.radioshack.com/graphics/uc/r … _DS_EN.pdf it says its a 12v coil, does that mean i cant switch it with 5v?
I will be purchasing LED strips in the future. right now I am testing with a single 5v red LED.
The reason I am posting this thread is because I do not know much about electronics at all.
These are my questions.
Why does this code only blink the LED connected to GND and CTS slowly?
#include <iostream>
#include <stdio.h>
#include <ftdi.h>
using namespace std;
#define LED 0x08 // cts line on cable
int main()
{
unsigned char c = 0;
struct ftdi_context ftdic;
ftdi_init(&ftdic);
cout << ftdi_usb_open(&ftdic, 0x0403, 0x6001) << endl;
ftdi_set_bitmode(&ftdic, LED, BITMODE_BITBANG);
// ftdi_set_baudrate(&ftdic, 3000000);
// ftdi_write_data_set_chunksize(&ftdic, 1);
c ^= LED1; // c = 8
// c = 255;
for( ; ; ) ftdi_write_data(&ftdic, &c, 1);
}
Before running this code the led does not blink.
During executiin the LED binks regularly. 1 blink/second approximately
After stoping execution the LED continues to blink.
Uncommenting the commented lines produces the exact behavior.
While this code is running if I plug my relay switch into GND and CTS, where the LED would have blinked, nothing happens.
If i plug the relay switch into VCC and GND then, where the LED would blink, the switch turns on and stays on… ( i can here the click of the switch ).
I took the basic idea of this code from this website http://hackaday.com/2009/09/22/introduc … bang-mode/ I’m going to test exactly what happens to my LED when the example code is used from this site tonight just to double check. I always was confused what the line ```
c ^= LED
I just read the FTDI Application Notes on BitBang Mode for their 232r devices here [http://www.ftdichip.com/Support/Documen ... Ft245R.pdf](http://www.ftdichip.com/Support/Documents/AppNotes/AN_232R-01_Bit_Bang_Mode_Available_For_FT232R_and_Ft245R.pdf) and am going to rethink my blinking code tonight.
Will a mechanical DPDT relay switch fast enough for my application? (greater than or equal to 60 times/second)
If not, should I use a solid state relay?
Does anybody have any suggestions? Ive considered using my raspberry pi I have laying around.
Any help is greatly appreciated, thanks.