Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - CaptClaude

Pages: 1
1
TinyLily / Re: Pinout documentation
« on: May 02, 2014, 02:07:27 AM »
Something else I am sure that everyone else knows but which I feel compelled to document here:  The a0, a1, a4 & a5 pins are also digital output pins.
THe next experiment will try and see if any of them are also PWM pins.
Code: [Select]
/*
  Blink a0, a1, a3, a4 pins
 */
 int pin;

void setup() {               
  // initialize the pins as an output.
  pinMode(14, OUTPUT);
  pinMode(15, OUTPUT);
  pinMode(18, OUTPUT);
  pinMode(19, OUTPUT);
 
}

void loop() {
  pin = 14;
  digitalWrite(pin, HIGH);   // set the LED on
  delay(1000);              // wait for a second
  digitalWrite(pin, LOW);    // set the LED off
  pin = 15;
  digitalWrite(pin, HIGH);   // set the LED on
  delay(1000);              // wait for a second
  digitalWrite(pin, LOW);    // set the LED off
  pin = 18;
  digitalWrite(pin, HIGH);   // set the LED on
  delay(1000);              // wait for a second
  digitalWrite(pin, LOW);    // set the LED off
  pin = 19;
  digitalWrite(pin, HIGH);   // set the LED on
  delay(1000);              // wait for a second
  digitalWrite(pin, LOW);    // set the LED off

}

Let's not all chime in here at once...

Cheers.

2
TinyLily / LED PWM fade up-down beginner example
« on: April 30, 2014, 12:59:54 AM »
On the off chance that someone is interested in a little beginner project, this code will fade an LED (or some LEDs) up and down.
My circuit takes Pin 3 through a 100Ohm resistor into the base of a little Darlington transistor.  4 purple LEDs in parallel are in the collector circuit to +4.5V, the emitter is grounded.  I have some yellow LEDs and they have a lower forward voltage so I put them two in series in parallel with another two in series.

Code: [Select]
/*
TinyLily LED fade up-down PWM test
LED is attached to pin 3 in series with an appropriate resistor
I only know for sure that pin 3 is a PWM pin.
Pin 2 does not PWM when LEDpin = 2, LED goes on and off.
Pin 0 & 1 are associated with the USB/serial port and are active while uploading the sketch
This sketch does not work when powered from USB, only when powered externally (3xAA).  Why?
*/
int i = 0;
int LEDpin = 3;

void setup() {
  pinMode(LEDpin, OUTPUT); // this is optional, sketch works without it
  digitalWrite(LEDpin, LOW); // this is also optional, sketch works without it
}
void loop()
{
// Fade up
  for(i = 0 ; i <= 255; i+=1)
  {
    analogWrite(LEDpin, i);
    delay(10);
  }

// fade down
  for(i = 255 ; i >= 0; i-=1)
  {
    analogWrite(LEDpin, i);
    delay(10);
  }

}


Hey, you gotta start somewhere, right?

Cheers.

3
TinyLily / Re: Pinout documentation
« on: April 30, 2014, 12:54:38 AM »
I have at least in part answered my own question:  Pin 3 is a PWM pin -- we know this because the motor sketch example uses it.  :-[
I would still like to know if there are any other pins that can PWM.

The really interesting thing is that my test sketch does not run when connected to USB, only when run off external power (3xAA works great).

Cheers.

4
TinyLily / Re: Pinout documentation
« on: April 29, 2014, 12:26:25 AM »
After some tinkering, I managed to get some LEDs to blink.  When connected to the USB thingie, pins 0 & 1 are not useful but when connected to 3xAA batteries, they work OK, but 0 always glows before the sketch gets moving after applying power.  If blinking LEDs is the goal (and for me, believe it or not, it is), best not use 0 at all.

Can the analog pins be PINMODE-ed to digital?  If so, what are their pin numbers?  I know for instance that there is no pin 4 because
Code: [Select]
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
and then
Code: [Select]
digitalWrite(4, HIGH);   // set the LED on
delay(3000);              // wait for 3 seconds
digitalWrite(4, LOW);    // set the LED off
Does nothing.

The end goal is to use the tinylily to drive (though a couple of transistors) some HB LEDs to illuminate some (found on Amazon) fiber-optic flowers to be used as stage props in a production of Shakespeare in Hollywood.  I am trying to get a "breathe"-style but the first adapted sketch I tried didn't work and my attempts at dimming with
Code: [Select]
void loop()
{
  for(i = 0 ; i <= 255; i+=1)
  {
    analogWrite(LEDpin, i);
    delay(20);
  }
  for(i = 255 ; i >= 0; i-=1)
  {
    analogWrite(LEDpin, i);
    delay(20);
  }

}
tonight have not gone anywhere -- the LED comes ON and then goes OFF.  It's been a while since my last Arduino project (likewise for the theatre) so my brain may be rusted shut.

Are there restrictions on which pins can PWM and which not?

Thanks!

Pages: 1
SMF spam blocked by CleanTalk