I've been putzing around with this most of the day and I'm sure it's something simple...
I'm trying to get a coded PWM value from my ATtiny to drive a mosfet which will drive a nano muscle.
Here's the driver:
I'm making good progress on this project but this has me stuck.
I'm trying this code
/*
Fade
This example shows how to fade an LED on pin 9
using the analogWrite() function.
This example code is in the public domain.
*/
int brightness = 0; // how bright the LED is
int fadeAmount = 1; // how many points to fade the LED by
void setup() {
// declare pin 9 to be an output:
pinMode(0, OUTPUT);
}
void loop() {
// set the brightness of pin 9:
analogWrite(0, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
with an LED but it's funky. The LED does fade but it blinks while doing so. It's a pretty neat effect but not what I was looking for
I've tried just using analogWrite with different values and it still blinks.
Any input? Fooling with these little stand alone chips is REALLY neat! And I'm getting a real kick out of it!
Seems that my 12V power supply was causing some weirdness This stand-alone stuff introduces it's own set of troubles, especially when other stuff is on the same circuit and AC comes into play...
Here's what I'm fooling with:
It's a NM70R-2P nano muscle in case anyone is wondering. The MAD5 driver is zip-tied to it.
This is the code running it:
int pin = 0; // LED connected to PWM pin 11
int pulsewidth = 20; // Any value between 0 and 255
void setup() {
// None required for analogWrite!
}
void loop() {
analogWrite(pin, pulsewidth);
delay(3000);
analogWrite(pin, 0);
delay(3000);
}
When the LED is illuminated the muscle is "flexing" and it's "relaxing" under it's own power (A spring I suppose) when the LED is off. You can see in the video that there isn't a lot of rotation. I needed the PWM because without it it just "snaps" into position when 5V is placed on the gate.
The migamotors site has some info on driving them with an Arduino.
Sorry about posting before I had exhausted all options
Now I need t shrinkify my voltage regulator. Any ideas on that? I haven't even began looking... And a small battery. I'm thinking one from an electric cigarette would work well. I imagine power consumption/duty cycle would be similar.
hoff70:
Now I need t shrinkify my voltage regulator. Any ideas on that? I haven't even began looking... And a small battery. I'm thinking one from an electric cigarette would work well. I imagine power consumption/duty cycle would be similar.
Thanks again for the help!
Not sure what a "nano muscle" is but:
Getting a smaller voltage regulator is absolutely no problem. They are available in a variety of packages including TO-92 or small surface mount packages with various current handling capacities. Also if you use a battery with less then 5.5v output, you do not need a voltage regulator.