Show Posts
|
|
Pages: 1 2 [3] 4 5 ... 41
|
|
31
|
Using Arduino / LEDs and Multiplexing / Super Bright Red Led - BC547B Transistor, but which Resistors?
|
on: September 05, 2012, 08:57:24 am
|
Guys, hope someone could help me with the math, as I can't figure this out just yet.  I plan on using a BC547B NPN transistor to switch On/Off a Super Bright Red Led. But I need to know the resistor for the LED and the resistor for the Transistor. I plan on using a Shift Register (74HC595) to drive 16 Leds from the Arduino. So, the 74HC595, each output pin goes to one BC547B Transistor base via a Resistor, and so on ... I can draw this if required, but you could also check this page out instead. http://www.sqlskills.com/blogs/paulselec/post/Arduino-figuring-out-transistors-and-associated-resistors.aspxI see he did reply about such question, but the transistor and led I'm using may be a bit different from what I see... Thanks for any help. Best Regards, WilliamK
|
|
|
|
|
32
|
Using Arduino / Project Guidance / 16 Touch Sensors - its working [code] but I wonder ...
|
on: September 04, 2012, 02:34:42 pm
|
So, I wanted to push this tutorial to its limits, making 16 touch sensors (I'm using screws for that) http://www.arduino.cc/playground/Code/CapacitiveSensorAnd using a 16 channel analog multiplexer (this is the one I actually tested with) https://www.sparkfun.com/products/299So far so good, it works. But I just want to double check things out, to be sure it won't burn something after hours of usage. ;-) Here's the test code I created, I'm just using an Arduino UNO + the multiplexer, nothing else. Thanks for any advice!  #include "pins_arduino.h" // Arduino pre-1.0 needs this volatile uint8_t* port; volatile uint8_t* ddr; volatile uint8_t* pin; byte bitmask; #define pinToMeasure 8 uint8_t values[16] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; uint8_t buttons[16] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; uint8_t buttonEvent[16] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; // 1 == normal push, 2 == hold push // char printOut[16*2]; uint8_t counterIdle = 0; #define oversample 8 #define sensitivity (4*oversample)
void setup() { for (char x=2; x<12; x++) pinMode(x, OUTPUT); for (char x=2; x<12; x++) digitalWrite(x, LOW); Serial.begin(9600); port = portOutputRegister(digitalPinToPort(pinToMeasure)); ddr = portModeRegister(digitalPinToPort(pinToMeasure)); bitmask = digitalPinToBitMask(pinToMeasure); pin = portInputRegister(digitalPinToPort(pinToMeasure)); }
void loop() { memset(values, 0, sizeof(values)); for (uint8_t y=0; y<oversample; y++) { for (uint8_t x=0; x<16; x++) { digitalWrite(2, bitRead(x,0)); digitalWrite(3, bitRead(x,1)); digitalWrite(4, bitRead(x,2)); digitalWrite(5, bitRead(x,3)); values[x] += readCapacitivePin(); } }
uint8_t buttonchanged = 0; for (uint8_t x=0; x<16; x++) { if (values[x] <= (sensitivity/2) && buttons[x] > 0) { if (buttons[x] < 99) { buttonEvent[x] = 1; buttonchanged = 1; } buttons[x] = 0; } else if (values[x] > sensitivity && buttons[x] < 120) { buttons[x]++; if (buttons[x] == 99) { buttonEvent[x] = 2; buttonchanged = 1; } } } if (buttonchanged) { Serial.print(":"); for (uint8_t x=0; x<16; x++) { if (buttonEvent[x] == 1) Serial.print("#:"); else if (buttonEvent[x] == 2) Serial.print("@:"); else Serial.print("_:");
buttonEvent[x] = 0; } Serial.println(""); counterIdle = 0; } counterIdle++; if (counterIdle > 100) { Serial.println(""); counterIdle = 0; } }
uint8_t readCapacitivePin() { *ddr &= ~(bitmask); // Make the pin an input with the internal pull-up on *port |= bitmask; uint8_t cycles = 6; for(uint8_t i = 0; i < 6 ; i++) // Now see how long the pin to get pulled up { if (*pin & bitmask){ cycles = i; break; } } *port &= ~(bitmask); // Discharge the pin again by setting it low and output *ddr |= bitmask;
return cycles; }
|
|
|
|
|
35
|
Using Arduino / Audio / Sampler - writing to the internal Flash and other crazy things.
|
on: August 16, 2012, 11:23:20 am
|
Ok, so I read that it IS possible to write to the flash area in real-time, its slow, but its possible, that's what the bootloader actually does. So, I was just daydreaming of a small sampler using the arduino. I already did a 6 voice drum playback from flash in the following project, and it works great. (8 bit, mono one shot samples read from the flash) https://github.com/Beat707/BeatVoxBut what if I could change all samples by reading from a SD card and replacing the flash contents? Of course, we couldn't do too many times, as the flash can be written only 100,000 times, so its more like during a live performance, you would change all drum sounds once or twice, so it should be ok. Even if you did 10 changes every single day, you would end up with 27 years total. ;-) But, I couldn't figure out yet how to handle this flash programming thing. From what I could see, the best thing would be to have a buffer set in the flash, and know the address and size of this buffer, so its always fixed, and use that. Something like that. I know that the process would be slow, to read from the SD and re-flash this area, but time wouldn't be a big issue. As long as it wouldn't take more than a minute, of course, but I doubt, since flashing the BeatVox + samples at a 30k of flash doesn't take a minute with a Due.2009 card, and its just a few seconds with an Uno card. Has anyone created a nifty library for doing this? Anyway, just a crazy idea. ;-) Best Regards, WilliamK
|
|
|
|
|
41
|
Using Arduino / Displays / Re: DIY Touch Screen from a simple Glass?
|
on: July 27, 2012, 10:13:17 am
|
Ahh, I think I got it wrong, I get to trigger and wait for the echo on each ultrasonic device, so I can have multiple ones, it doesn't mater, so it would work with multiple ones, and they are pretty cheap.  I will test with the one I got here, and order some more. ;-)
|
|
|
|
|
42
|
Using Arduino / Displays / Re: DIY Touch Screen from a simple Glass?
|
on: July 27, 2012, 10:10:22 am
|
Indeed, I'm wondering about that too. It would require a good DAC and good insulation from the external world. Another idea I'm wondering, is using 2 Ultrasonic Readers. But the problem is that the second one must use a different frequency or something that would interfere with the first one. http://www.ebay.com/itm/HC-SR04-Ultrasonic-Distance-Module-Sensor-Compatible-Arduino-HCSR04-/300734849813?pt=LH_DefaultDomain_0&hash=item460531a315Then use a single touch chip IC (like the quantum chip) to know when the glass/plexy was touched, then it reads the position from both ultrasonic devices. Its crazy, but it should work, unless a single finger doesn't give enough echo back to the sonic device. Plus, it may require multiple devices as their field is narrow from what I know. I have one just like the above to test, just need to figure out how to use 2 now... maybe the SR05 uses a different frequency? Or it doesn't matter much, as the echo will be different to X and Y anyway? Just wondering. Need to order another one to test I guess...
|
|
|
|
|