Christmas star redo

Status
Not open for further replies.

MrDEB

Well-Known Member
Decided while waiting for parts to redo the Christmas star project but using Diptrace instead of EASYEDA files.
I attempted to start where I left off but couldn't make heads or tails of what I was doing so back to Diptrace.
going with 35 LEDs and 4x resistor arrays.
Am looking at using PWM on several LEDs but the 18f43k22 shows none?
Discovered reading the data sheet that port R3 is input only.
here is my new schematic
 
OUPS! Iwhile starting the pcboard design I discoveredI need to change the connections to 3 of the resistor arrays
 
Am looking at using PWM on several LEDs but the 18f43k22 shows none?
Not sure what that means. The 18F4xK22 has 5 hardware PWM peripherals... ECCP1, ECCP2, ECCP3, CCP4, and CCP5

On that device they come out on fixed pins: RC2, RC1/RB3, RB5/RE0, RD1, and RE2.
The pin selections for ECCP2 and ECCP3 are done using CONFIG settings.
 
Even though there are 35 LEDs, you could probably just use software PWM to get different outputs since the uC doesn't have anything else to do.
 
yes I thought about that as well.
I also see I have one input only pin, re3
Had to redo my posted schematic as the LEDS are jumbled up making traces go every which way. Same issue I had last year using EASYEDA.
Plus last year I had two LEDS per port but using 805 sized LEDs. Using 1202 this year.
 
Been searching for a "shirmming star" for my Christmas star project. I thing I found some code from 2016 that basically does a decent shimmer.
been changing and adding to get desired effect. Basically decontructing to see what makes it tick
My new boards should be here this week as well as 18f2221 chips for stars boards 2018 using a 18f2221
new boards are using 18f23k22
Code:
{

{
*****************************************************************************
*  Name    : UNTITLED.BAS                                                   *
*  Author  : [select VIEW...EDITOR OPTIONS]                                 *
*  Notice  : Copyright (c) 2016 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 11/29/2016                                                     *
*  Version : 1.0                                                            *
*  Notes   : star with a shimmer need to duplicate for 18f43k22                                                               *
*          :                                                                *
*****************************************************************************
}
 Device = 18F2221 ' Tell the compiler what chip we are using
Clock = 8 ' Tell the compiler what we will be setting the clock to (Mhz)
Config MCLRE = OFF
Include "intosc.bas"
#option DIGITALIO_INIT = true       // automatically call setalldigital
Include "setdigitalio.bas"
Include "convert.bas"
Include "Utils.bas"
Include "RandGen.bas"
// Read the AD ports and scale for the cds 
    
    'FUNCTION Dsired_T() AS WORD  //Dsired-T is speed selection
    ' result = (ADC.Read(0) +1)*500 /1024  //Read DESIRED TEMP Adjustment vis ADC
    'END FUNCTION
  
  
 //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Dim time As Word
Dim pressed As Byte
Dim x As Byte
Dim y As Byte
 
'DIM led0 AS PORTa.0  //ADC input
Dim LED1 As PORTA.1
Dim LED2 As PORTA.2
Dim led3 As PORTA.3
Dim led4 As PORTA.4
Dim LED5 As PORTA.5
Dim LED6 As PORTA.6
Dim LED7 As PORTA.7

Dim led8 As PORTB.0
Dim led9 As PORTB.1
Dim led10 As PORTB.2
Dim led11 As PORTB.3
Dim led12 As PORTB.4
Dim led13 As PORTB.5
Dim led14 As PORTB.6
Dim led15 As PORTB.7

Dim led16 As PORTC.0
Dim led17 As PORTC.1
Dim led18 As PORTC.2
Dim led19 As PORTC.3
Dim led20 As PORTC.4
Dim led21 As PORTC.5
Dim led22 As PORTC.6
Dim led23 As PORTC.7
'DIM led16 AS portc.4
Dim ms As Word
Dim us As Word
Dim RandomVal As Byte
Dim Et As Byte

// sub routines

'OUTPUT (led0)
Output (LED1)
Output (LED2)
Output (led3)
Output (led4)
Output (LED5)
Output (LED6)
Output (LED7)
Output (led8)
Output (led9)
Output (led10)
Output (led11)
Output (led12)
Output (led13)
Output (led14)
Output (led15)
Output (led16)
Output (led17)
Output (led18)
Output (led19)
Output (led20)
Output (led21)
Output (led22)
Output (led23)

LED1 =0
LED2 =0
led3 =0
led4 =0
LED5 =0
LED6 =0
LED7 =0
led8 =0
led9 =0
led10 =0
led11=0
led12 =0
led13=0
led14=0
led15=0
led16 =0
led17 =0
led18 =0
led19=0
led20=0
led21 =0
led22=0
led23 =0
time = 50
' time = 20
  Et = 5



x = 0
RandGen.Initialize(128)       // Initialize the Random Number generator
'SetAllDigital
// main program...
// Vairy the time to flicker the leds
While true
  RandomVal= RandGen.Rand  // Grab a random number from 0 to 255
 
  'us = ms
 
 LED1=1
 'DELAYMS(time)
 'toggle (led1)
 'DELAYMS(time - 1000)
 LED2=1
 'DELAYMS(time)
 'toggle (led2)
 
 led3=1
 'DELAYMS(time)
 'toggle (led3)
 
 led4=1
 'DELAYMS(time)
 'toggle (led4)
 
  LED5=1
 'DELAYMS(time)
' toggle (led1)
' toggle (led3)
 
 LED6=1
 'DELAYMS(time)
 'toggle (led6)
 
 LED7=1
 'DELAYMS(time)
 'toggle (led7)
 
 led8=1
 'DELAYMS(time)
 'toggle (led2)
 'toggle (led5)
 ' led9=1
 'DELAYMS(time)
 'toggle (led9)
 
 led10=1
 'DELAYMS(time)
 'toggle (led10)
 
 led11=1
 'DELAYMS(time)
 'toggle (led11)
 'toggle (led3)
 'toggle (led7)
 led12=1
 'DELAYMS(time)
 'toggle (led12)
 
  led13=1
 'DELAYMS(time)
 'toggle (led13)
 
 led14=1
 'DELAYMS(time)
 'toggle (led14)
 
 led15=1
 'DELAYMS(time)
 'toggle (led15)
 
 led16=1
 'DELAYMS(time)
 'toggle (led16)
 
  led17=1
 'DELAYMS(time)
 'toggle (led17)
 
 led18=1
 'DELAYMS(time)
 'toggle (led18)
 
 led19=1
 'DELAYMS(time)
 'toggle (led19)
 
 led20=1
 'DELAYMS(time)
 'toggle (led20)
 
  led21=1
 'DELAYMS(time)
 'toggle (led21)
 
 led22=1
 'DELAYMS(time)
 'toggle (led22)
 
 led23=1
 'DELAYMS(time)
 'toggle (led23)
  time= RandGen.Rand  // Grab a random number from 0 to 255
  'time = RandomVal
 
  Select time
         Case >244 Toggle (LED1)DelayMS(Et) //
         Case >233 Toggle (led23)DelayMS(Et)//
         Case >222 Toggle (led20)DelayMS(Et)//
         Case >211 Toggle (led4)DelayMS(Et) //
         Case >200 Toggle (led15)DelayMS(Et) //
         Case >189 Toggle (led16)DelayMS(Et) //
         Case >178 Toggle (LED2)DelayMS(Et)   //
         Case >167 Toggle (led8)DelayMS(Et)   //
         Case >156 Toggle (led19)DelayMS(Et) //
         Case >145 Toggle (led10)DelayMS(Et) //
         Case >134 Toggle (led11)DelayMS(Et) //
         Case >123 Toggle (led3)DelayMS(Et)  //
         Case >112 Toggle (led13)DelayMS(Et) //
         Case >101 Toggle (led14)DelayMS(Et) //
         Case >90 Toggle (LED5)DelayMS(Et) //
         Case >79 Toggle (led22)DelayMS(Et)
         Case >68 Toggle (led17)DelayMS(Et) //
         Case >57 Toggle (led12)DelayMS(Et)//
         Case >46 Toggle (led9)DelayMS(Et) //
         Case >35 Toggle (led18)DelayMS(Et)//
         Case >24 Toggle (LED6)DelayMS(Et) //
         Case >13 Toggle (led21)DelayMS(Et)//
         Case >1 Toggle (LED7)DelayMS(Et)   //
        
         End Select
Wend








{
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…