Star Trek into Darkness: Klingon heavy disruptor [electronic help needed!]

I did the first one, and the built-in LED went from 'normal on' to 'brighter on'.
The other gave me an error, saying COM3 was already in use?

LED shouldn't be on at all unless you are uploading code. Did you try this with the Arduino disconnected from USB and running on the battery pack? And with the battery pack connected directly to the 5v and gnd pins? At 4.5 volts, it MAY run through the "V in" but it will be inconsistent and buggy.


When do you get the "com3" error on the second sketch? When you compile, or when you upload? I just tried a test compile with my IDE set to "Arduino Micro" (I don't have an actual micro to test) and it compiles without error.

We'll get there. Wrong results are a lot more informative than no results at all!
 
It's no 4.5 volts, it's 6V because I couldn't get a 3-batt holder. But yes, I did that one without the usb. I uploaded the sketch, then disconnected and pressed the button. It just started glowing a little brighter.

Regarding the second bit, i think compiling went fine. I thought the failure came with uploading. I'll check tomorrow, it's 2:45AM and I should get some sleep ;)


Sent from my iPhone using Tapatalk
 
Allright, we'll pick it up in the morn. Email me if you like -- site mail goes there too.



(Oops. 6v is a bad value -- a little too high for the Arduino unregulated, but still too low to get good results from the regulator. Also brings the resistor up to 8 ohms and a honking 2 watts value -- a 1-watt will do but I wouldn't go a lot lower. But all is not lost! You can take a piece of jumper wire and solder it in place of one of the batteries, converting it to a 3-cell holder.)
 
Last edited:
EDIT:

All I know for sure is that LED on pin 13 should be off (LOW) when the Arduino is powered up and
should then turn on (HIGH) when the button is pressed.

I have access to an Arduino UNO and I loaded this code in to it as written and LED 13 was lit all the time:

int pressed = 0;

void setup(){
pinMode(8, INPUT);
pinMode(13, OUTPUT);
}

void loop(){
pressed = digitalRead(8);
if (pressed){
digitalWrite(13, LOW);
}
else{
digitalWrite(13, HIGH);
}
}

There is problem I see, pin 8 should change states (go from HIGH to LOW when
the button is pressed), but I don't see on either of the schematics a 10k resistor directly from pin 8 to + (positive)?

The 10k resistor would pull pin 8 HIGH, then when the button is pressed, it would go to ground (LOW).
So I added the 10k resistor and it works OK.

Without the 10k, pin 8 just "floats" while the button connection is open and the ARDUINO doesn't
see any state (except an open pin).


Just my thoughts :)

propmaster2000

EDIT:

I had a chance to test this code as well:

#define button 8 //button is wired to this pin; see the pinoout
#define cree 9 //and this goes to the LED

int pressed = 0;
int bright = 255;


void setup()
{
pinMode(button, INPUT);
pinMode(button,INPUT_PULLUP);
analogWrite(cree, 0);
}

void loop()
{
pressed = digitalRead(button);
if(pressed == LOW)
{
bright = 255;
analogWrite(cree, bright);
delay(1000); ///this arbitrary delay keeps the LED at full power for a moment
for (bright = 255; bright > 0; bright --)
{
analogWrite(cree, bright);
delayMicroseconds(50); // this value changes how quick the fade is
}
pressed = HIGH;
}
}

and an LED on pin 9 is off when the ARDUINO is powered up.
When I push the button (momentarily), the LED lites for about a second then shuts off.
There does not seem to be any FADE effect.


EDIT again:

See my next posting

.
 
Last edited:
I fixed the battery holder. It works, arduino gets power.

2pZVzPel.png


Also, I figured to show some pics of how it looks right now.

Z7qCYntl.jpg


2Hoo8Iml.jpg


HughfNkl.jpg


eUAJbl4l.jpg


BBXnUlql.jpg


iR04VmOl.jpg


And because I'm such a serious cosplayer.... *cough*


9PSR8ecl.jpg


gtBi6Ovl.jpg


Deadly leafblower strikes again.
 
Yeah, that all sounds right. There's a few differences between Arduino's and the various generations of the IDE -- sometimes the internal pullup is on by default, other times you have to declare it as per that additional statement I left out of the short sketch.

And the fade sounds right...I estimated low rather than high, so the trick is to increase the delay values until the fade is properly visible. I probably should have started with a long delay first and worked down -- easier to diagnose! When I'm writing my own test sketches, I usually default to delay(800) to make sure I notice something is on.


EDIT:

All I know for sure is that LED on pin 13 should be off (LOW) when the Arduino is powered up and
should then turn on (HIGH) when the button is pressed.

I have access to an Arduino UNO and I loaded this code in to it as written and LED 13 was lit all the time:

int pressed = 0;

void setup(){
pinMode(8, INPUT);
pinMode(13, OUTPUT);
}

void loop(){
pressed = digitalRead(8);
if (pressed){
digitalWrite(13, LOW);
}
else{
digitalWrite(13, HIGH);
}
}

There is problem I see, pin 8 should change states (go from HIGH to LOW when
the button is pressed), but I don't see on either of the schematics a 10k resistor directly from pin 8 to + (positive)?

The 10k resistor would pull pin 8 HIGH, then when the button is pressed, it would go to ground (LOW).
So I added the 10k resistor and it works OK.

Without the 10k, pin 8 just "floats" while the button connection is open and the ARDUINO doesn't
see any state (except an open pin).


Just my thoughts :)

propmaster2000

EDIT:

I had a chance to test this code as well:

#define button 8 //button is wired to this pin; see the pinoout
#define cree 9 //and this goes to the LED

int pressed = 0;
int bright = 255;


void setup()
{
pinMode(button, INPUT);
pinMode(button,INPUT_PULLUP);
analogWrite(cree, 0);
}

void loop()
{
pressed = digitalRead(button);
if(pressed == LOW)
{
bright = 255;
analogWrite(cree, bright);
delay(1000); ///this arbitrary delay keeps the LED at full power for a moment
for (bright = 255; bright > 0; bright --)
{
analogWrite(cree, bright);
delayMicroseconds(50); // this value changes how quick the fade is
}
pressed = HIGH;
}
}

and an LED on pin 9 is off when the ARDUINO is powered up.
When I push the button (momentarily), the LED lites for about a second then shuts off.
There does not seem to be any FADE effect.


EDIT again:

See my next posting

.
 
Oh, and I should have added -- that's why the LED is on but lower intensity. I'd bet money if you hooked up the serial monitor, you'd see the button status going "on/off/on/off/on/off/on/off..." at up to a few kilohertz.

- - - Updated - - -

Ooh, that looks great and you look cool and dangerous with it.

Oh nice! Yes please! That's the effect I'm looking for :)
 
Hmm... I'm afraid I might have screwed up on the wiring. Might have to re-check my transistor. I don't really get why it doesn't work, because I followed the schemes, but hghhg

Edit: If I replace the #define cree 9 //and this goes to the LED with #define cree 13 //and this goes to the LED
The built-in LED does indeed react to the button. This indicates that at least the button is wired correctly to the arduino. To me at least.
 
Last edited:
As I mentioned earlier, I know nothing about how to interpret code for the ARDUINO, I just cut and paste until it works for me.

I used an UNO because this is what I had available here, so I don't know if any other ARDUNIO version will work.
Also, it may also depend on which version of the software is running the micro-controller.
I am using Arduino 1.0.5-r2

I know however that a 10k resistor from pos. to pin 8 made all the difference for me.

(Also, I used a single Blue LED. (ground - resistor - LED - pin 9) to see the output from pin 9.)

That should mean that there is a positive signal coming from pin 9 and that would drive an NPN transistor
through a resistor.

I don't know how the TIP120 NPN will operate from this FADE signal, but it should do something....
BASE - COLLECTOR - EMITTER

arduino.jpg

Here is the code I loaded to the UNO:


// Tested with UNO

const int button = 8; // the number of the pushbutton pin
const int cree = 9; // the number of the LED pin

int pressed = 0;
int bright = 255;


void setup()
{
pinMode(button, INPUT);
pinMode(button,INPUT_PULLUP);
analogWrite(cree, 0);
}

void loop()
{
pressed = digitalRead(button);
if(pressed == LOW)
{
//bright = 255;
analogWrite(cree, bright);
delay(800); // this value changes the ON time before the FADE begins

for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5)
{
analogWrite(cree, fadeValue);
delay(15); // this value changes the quickness of the FADE
}
}
}

I hope this helps :)
 
Last edited:
Look forward to seeing your code. I've been using a hand-rolled version of the "blinkM" that I wrote a while ago and have been adapting since -- not the easiest code to hand off to someone else at this point, not with the rand functions and lookup tables and stuffs. This was the last project I was using it on:

tiny_cree.JPG

(Quickie fire effect, using just the red and green channels, done as a proof-of-concept.) One of these days I'll finish a generic PCB with three channels for PWM'ing 3W RGB's...

The pictures look great!
If you are still looking to get your CREE LED working with the Arduino, I managed to get a single LED to light and fade on my UNO.
Below is a link to the effect:
http://www.youtube.com/watch?v=Rk8J9cftcMc
 
Hmm... I'm afraid I might have screwed up on the wiring. Might have to re-check my transistor. I don't really get why it doesn't work, because I followed the schemes, but hghhg

Edit: If I replace the #define cree 9 //and this goes to the LED with #define cree 13 //and this goes to the LED
The built-in LED does indeed react to the button. This indicates that at least the button is wired correctly to the arduino. To me at least.

Great!

That's with the PULLUP in the code, right? Looks like that is mandatory on your board.

If you are using my first "fade" sketch, increase all the delay() statements by 4x. That will make it easier to see what is going on.

And do the leg-brush test I mentioned; disconnect the transistor from the arduino completely, and using the resistor that's on the base, brush it to V+ and see if the LED lights. If not, look on the package -- you might have emitter/base/collector in a different arrangement than they are in the image.
 
Sorry, we're talking Geek again. What happens, is digital inputs "float." If they don't have a connection to a reference point, then they slowly gather charge from the atmosphere, and drift around until they are at a value that could be interpreted as a 0 or as a 1. And the internal circuitry can't make up it's mind; it wanders back and forth from one to the other.

You usually need to force the input to one end or the other. Standard practice is to make it drift HIGH by attaching it to V+ with a high-value resistor. There's practically no current flow through the resistor, and the amount it can pull HIGH completely loses the tug-of-war towards a button wired directly to GND. So the resistor keeps it reading a steady "HIGH" and when you ground it through the button, it goes to a clean "LOW."

On the Arduino, there is a set of these same "pull-up resistors" inside the chip itself, but they have to be switched on via software. The "pinMode(button,INPUT_PULLUP);" routine which was added to the Arduino code base fairly recently is a painless way of doing this. Still, a lot of old-timers will just attach a physical resistor anyhow. We feel safer with that!
 
Ok I now have

  • a 220K resistor connected to pin 9, which then goes to (I think) the BASE pin on the transistor. From the COLLECTOR flows a wire to the minus side of the CREE. From the EMITTER pin flows a wire to a connection point which ends up at the negative side of the circuit & battery pack.
  • Then from pin 8, I have a wire going to the pulse button, which too, is connected to the connection point on the negative side of the circuit & battery pack.
  • At GROUND, I have a wire that's directly connected to the connection point at the negative side & battery pack.
  • At 5V I have a wire that connects to the positive side of the circuit & battery pack.
  • From the positive wire at the battery pack, there's a 3.9Ohm resistor, connected to the plus side of the CREE.

Is there something wrong?

I thought that maybe the 220K resistor isn't the right one. I couldn't remember the correct one and saw 2.2K & 220K and I think I soldered in the wrong one. Easy fix though.
 
That 220K should probably be a 2.2K -- it is slightly risky, but you can jumper over it entirely to see if that is the problem (it isn't electrically mandatory; it's there to protect the Arduino's outputs from trying to push too many amps).


Oh. And you need either that 220K resistor to V+ from the input the button is on, or add the INPUT_PULLUP line to your code. Otherwise the button will not work reliably.
 
Err...don't forget the engineer's dictum.

TEST the Cree+Transistor without any other circuitry connected to it

TEST the button-and-fade-code using the built-in LED and with the Cree et al disconnected
 
Ok I replaced the resistor and the CREE works AND fades.

But doesn't respond to the button *yet* We're getting there!
 
Yay!

Okay...gonna get "dangerous" here. Edit the #def again to point at the built-in LED on 13 (is easier to work isolated). Now go back up to void setup() and add "pinMode(button,INPUT_PULLUP);"

If we can get the internal resistor working it is safer than trusting the soldering on another external resistor.



Err....

I'm going to assume that by "Fades" you mean; as soon as the software is loaded (the activity stops on the tx and rx LEDs) the Cree lights up, then over a few seconds fades to nothing. Then never comes on again. Right? Because if that's what is happening, it means the button is reading false positive and so we just need to solve the button.
 
Back
Top