Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

computer Christmas lights

MrDEB

Well-Known Member
years ago I assembled a Compurterized Christmas light display but since sold the entire setup.
I recall the SSR or triac boards used an opti-isolator, couple resistors but instead of using a computer, I want to just use a PIC to drive the opti_isolator. Just started looking for leftover plans and parts but figure would ask first.
 
That's odd, since this schematic is a png file.

You could change it to a jpg using Ifranview.

Schematic_junk1_2022-12-17.png
 
I used infaview and converted to a jpeg and hopefully it works
I added net labels and discovered why I fried the pic. I used the wrong port? B.0 and B.1
 

Attachments

  • sign_lights3.jpg
    sign_lights3.jpg
    435.3 KB · Views: 146
The error message I got and posted allowed extensions in post#240
sub, say, asc,asm, bas, bin, bmp, brd, bx2, c, doc, exe,gif, gz, h, hex, ino, jpeg
 
I guess you didn't read my explanation of why you CAN NOT turn on a single LED in a "row".
 
Yes I understand ONLY ONE LED PER ROW
here is how I hope to turn on 4 LEDs at a time then cycle from 1 - 4
Code:
{

{
*****************************************************************************
*  Name    : UNTITLED.BAS                                                   *
*  Author  : [select VIEW...EDITOR OPTIONS]                                 *
*  Notice  : Copyright (c) 2020 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 3/15/2020                                                      *
*  Version : 1.0                                                            *
*  Notes   : 4x4 matrix 12/18/22                                                               *
*          :                                                                *
*****************************************************************************
}
Module 4x4 ledmatrix


//LED MATRIX
Dim RED As PORTC.3
Dim WHITE AS PORTC.4
Dim BLUE AS PORTC.5
Dim GREEN AS PORTC.6
Dim ROW_1 As PORTB.5
Dim ROW_2 As PORTB.4
Dim ROW_3 As PORTB.3
Dim ROW_4 As PORTB.2

// make led pins outputs and turn them all off
Public Sub AllOff()
    // turn off columns
    Low(RED)
    Low(WHITE)
    Low(BLUE)
    Low(GREEN)
    // turn off rows
    High(ROW_1)
    High(ROW_2)
    High(ROW_3)
    HIGH(ROW_4)
End Sub

// turn on a single led
//  led_no = 0 -> nothing on (all off)
//         = 1 - 4 -> turn on specified led

Public Sub SetLed(led_no As Byte=0)
    AllOff()
    Select (led_no)
        
        Case 1     
            RED = 1
            ROW_1 =0
            WHITE = 1
            ROW_2 = 0
            BLUE = 1
            ROW_3 = 0
            GREEN = 1
            ROW_4 = 0
        Case 2     
            RED = 1
            ROW_2 =0
            WHITE = 1
            ROW_3 = 0
            BLUE = 1
            ROW_4 = 0
            GREEN = 1
            ROW_1 = 0
        Case 3     
            RED = 1
            ROW_3 =0
            WHITE = 1
            ROW_4 = 0
            BLUE = 1
            ROW_1 = 0
            GREEN = 1
            ROW_2 = 0
          
            
        Case 4     
            RED = 1
            ROW_4 =0
            WHITE = 1
            ROW_1 = 0
            BLUE = 1
            ROW_2 = 0
            GREEN = 1
            ROW_3 = 0
      
    End Select
End Sub
 SetLed()
// init
AllOff()

End Module
 
Yes I understand ONLY ONE LED PER ROW
here is how I hope to turn on 4 LEDs at a time then cycle from 1 - 4

That is exactly opposite of what I have explained twice already. YOUR ROWS ARE EITHER ALL ON or ALL OFF if your schematic is correct.

Since you're not going to even attempt to understand replies to your numerous problems, I'll stop wasting my time.
 
The rows are individually controlled by portb.2 - b.5 so ALL THE ROWS are not all on or off.
Unless you or I are missing something, but I have an actual board where the rows are independent of each other.
 
There are four separate COLUMNS - but there is no X-Y matrix, no rows.

All four LEDs are connected in parallel in each column, with both a colour and a "row" connection linked vertically to each column, rather than the row connections being across the columns to give the matrix connection.

That's how they are in the EasyEDA screen grab, anyway.
 
THIS is what YOUR schematic shows. The ONLY OPTIONS are ALL ON or ALL OFF. So either your SCHEMATIC is WRONG (imagine that) or your UNDERSTANDING OF THE CIRCUIT is wrong.

Screenshot_20221219_063950_Edge.jpg
 
now I am kinda lost?
using this snippet only one led per row is on?
maybe I am missing something?

Code:
 Basic
 Case 1 
            RED = 1
            ROW_1 =0
            WHITE = 1
            ROW_2 = 0
            BLUE = 1
            ROW_3 = 0
            GREEN = 1
            ROW_4 = 0
 
Last edited by a moderator:
THIS is what YOUR schematic shows. The ONLY OPTIONS are ALL ON or ALL OFF. So either your SCHEMATIC is WRONG (imagine that) or your UNDERSTANDING OF THE CIRCUIT is wrong.

LOOK AT YOUR SCHEMATIC, you know, the "corrected" one after I explained and drew you a picture of what it showed. Trace the circuit. Explain how it can possibly do as you claim (HINT: IT CANNOT).

You haven't taken the 30 seconds to understand what I posted over 10 posts ago.
 
I see my error so maybe with some code revisions,
Code:
  Case 1     
            RED = 1
            ROW_1 =0
            delayms(300)//enough to see ON?
            toggle(red)
            WHITE = 1
            ROW_2 = 0
            delayms(300)
            toggle(white)
            BLUE = 1
            ROW_3 = 0
            delayms(300)
            toggle(blue)
            GREEN = 1
            ROW_4 = 0
            delayms(300)
            toggle(green)
it will work?
note all the columns are off to begin with. toggle the columns(red, white etc.)
 
See posts 253, 250, 249, 246, 244, 235 and 233. See if you can spot any similarities in these posts.
 
I'm afraid MrDEB has missed the point. IF his schematic is accurate, then what he wants to do is impossible. If it is possible to turn on a single LED in a row, the schematic is incorrect.

In either event, nobody can keep with the code as it's either:

● Not possible to do want he wants

Or

● Nobody knows what's actually connected to what, so any comments on the code are useless.
 
Here is the correct schematic, not the one in #250
this code should work? It is TOGGLING the columns and rows
Maybe some confusion about using the 2 pin plugs. Here the LEDs are used instead.
I could be wrong but maybe not?
Code:
     Case 1     
            RED = 1
            ROW_1 =0
            DelayMS(300)//enough to see ON?
            Toggle(RED) // turn off RED
            WHITE = 1   //turn on WHITE
            ROW_2 = 0
            DelayMS(300)
            Toggle(WHITE)
            BLUE = 1
            ROW_3 = 0
            DelayMS(300)
            Toggle(BLUE)
            GREEN = 1
            ROW_4 = 0
            DelayMS(300)
            Toggle(GREEN)
 

Attachments

  • Schematic_TESTING_2022-12-20.png
    Schematic_TESTING_2022-12-20.png
    64.7 KB · Views: 141
You need to turn the rows off after each step to have a single LED illuminated.

As it is now, you'll have:

Step 1: 1 red LED illuminated

Step 2: 2 white LEDs illuminated

Step 3: 3 blue LEDs illuminated

Step 4: 4 green LEDs illuminated
 
Your 4x4 matrix can be turned on from a 16 bit variable and 4 LEDs can be illuminated at any one time via interrupt (very fast so it looks like all lit LEDs are on permanently). That way your main code can simply set the bit in the 16 bit variable. Plus your on time is 25% instead of 6%. You do realise that with 5V and 330Ω resistors and an on time of 6% the LED current will be ~0.5mA - not very bright. Dropping the resistor to 33Ω will increase it to 5mA .

Has anyone got an example of an ISR in swordfish basic?

Mike.
 

Latest threads

New Articles From Microcontroller Tips

Back
Top