Jump to content

Photo

Spleen's Arduino thread


  • Please log in to reply
10 replies to this topic

#1 SpleenBeGone

SpleenBeGone

    Deer Leader of the Goriest Revolution

  • Administrators
  • 14,535 posts
  • LocationHouston

Posted 11 October 2016 - 04:28 PM

So I've amassed some arduino parts by getting in over my head. I decided it's time to start small and work my way up. I'll be posting random do-dads I make here.

 

Step one was a blinking light, that was easy.

Step two was a copy/paste code to make a series of blinking lights.

 

Step three was to change the code and make a circle of blinking lights.


nmjUGDL.jpg

#2 SpleenBeGone

SpleenBeGone

    Deer Leader of the Goriest Revolution

  • Administrators
  • 14,535 posts
  • LocationHouston

Posted 17 October 2016 - 12:05 PM

Have to figure out that flicker at the end of the loop.

 


nmjUGDL.jpg

#3 fae

fae

    Terabyte

  • Members
  • 1,302 posts
  • LocationOver the hills, where the seven dwarfs dwell

Posted 17 October 2016 - 02:04 PM

I assume you use some kind of pwm for this. How do you calculate the duty cycle?

Et j'aime la nuit écouter les étoiles. C'est comme cinq cent millions de grelots. - Antoine de Saint-Exupéry


#4 SpleenBeGone

SpleenBeGone

    Deer Leader of the Goriest Revolution

  • Administrators
  • 14,535 posts
  • LocationHouston

Posted 17 October 2016 - 03:18 PM

Yes, it's PWM. From my basic knowledge, arduino lets you set the duty cycle in intervals from 0-255. At least that's what it seems like. Here's the original code I chopped up. 

/*
 Fade
 
 This example shows how to fade an LED on pin 9 up
 while fading a 2nd LED on pin 10 down
 using the analogWrite() function.
 
 
 */
int RedBrightness = 0;    // how bright the red LED is
int YellowBrightness = 255;    // how bright the yellow LED is
int fadeAmount = 5;    // how many points to fade the LED by

void setup()  {
  // declare pins 9, 10, to be outputs:
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
} 

void loop()  {
  // set the brightness of pin 9:
  analogWrite(9, RedBrightness);
  // set the brightness of pin 10:
  analogWrite(10, YellowBrightness);

  // change the brightness for next time through the loop:
  RedBrightness = RedBrightness + fadeAmount;
  YellowBrightness = YellowBrightness - fadeAmount;
  
  // reverse the direction of the fading at the ends of the fade: 
  // and blink the internal LED on pin 13 at the fade end point
  if (RedBrightness == 0 || RedBrightness == 255) {
    fadeAmount = -fadeAmount ; 
  }     
 
 
  // wait for 30 milliseconds to see the dimming effect    
  delay(30);
} 

nmjUGDL.jpg

#5 fae

fae

    Terabyte

  • Members
  • 1,302 posts
  • LocationOver the hills, where the seven dwarfs dwell

Posted 18 October 2016 - 02:21 AM

Maybe your LED is not linear :)


Et j'aime la nuit écouter les étoiles. C'est comme cinq cent millions de grelots. - Antoine de Saint-Exupéry


#6 SpleenBeGone

SpleenBeGone

    Deer Leader of the Goriest Revolution

  • Administrators
  • 14,535 posts
  • LocationHouston

Posted 18 October 2016 - 05:55 AM

Very possibly.

I'm in way over my head with this stuff, but it's fun to tinker. 


nmjUGDL.jpg

#7 fae

fae

    Terabyte

  • Members
  • 1,302 posts
  • LocationOver the hills, where the seven dwarfs dwell

Posted 18 October 2016 - 09:19 AM

Maybe you can fix it by just not going all the way to the 100% dutycycle on the red led.
Also you could encode a sinus instead of a saw it may possibly look nicer. Then you can also set the amplitude individually for both leds.

Et j'aime la nuit écouter les étoiles. C'est comme cinq cent millions de grelots. - Antoine de Saint-Exupéry


#8 SpleenBeGone

SpleenBeGone

    Deer Leader of the Goriest Revolution

  • Administrators
  • 14,535 posts
  • LocationHouston

Posted 18 October 2016 - 04:35 PM

I'll have to tinker with it tomorrow. 

Eventually I'm going to make a badass lamp. >.>


nmjUGDL.jpg

#9 fae

fae

    Terabyte

  • Members
  • 1,302 posts
  • LocationOver the hills, where the seven dwarfs dwell

Posted 18 October 2016 - 11:15 PM

Let me know how it goes

Et j'aime la nuit écouter les étoiles. C'est comme cinq cent millions de grelots. - Antoine de Saint-Exupéry


#10 Senpie

Senpie

    Byte

  • Members
  • 11 posts

Posted 23 October 2016 - 02:17 PM

That's neat! I've always been into things like this but I've been more into kits rather than Arduino. I may have to buy one and mess around with it.



#11 SpleenBeGone

SpleenBeGone

    Deer Leader of the Goriest Revolution

  • Administrators
  • 14,535 posts
  • LocationHouston

Posted 25 October 2016 - 07:18 PM

Let me know how it goes

It's going pretty well. Have the basic shape down. 

I'll get some pictures tomorrow.

 

 

That's neat! I've always been into things like this but I've been more into kits rather than Arduino. I may have to buy one and mess around with it.

I bought one a while back for another project and I've just been tinkering, it's a lot of fun. Right now I'm trying to make a LED cube.

 

14724595_10211081357889074_3102971647492


nmjUGDL.jpg