PIC 18 IO Double Chasing

The LEDs chase each other in both directions — Debut pic — Episode#06

J3
Jungletronics
2 min readNov 21, 2019

--

Hi, this project aimed at the joy of coding o/. The Joy of coding is all about the love for programming ❤ git

Fig 1. LEDs chasing each other in a cool fashion :D

There is no special application for this algorithm but fun.

Anyway here goes the code:

Fig 2. It will work on your easyPIC v7 board too :D pls gimme feedback o/

The important discovery is bitwise.

Bitwise is bit operations. It allows us to manipulate a single bit within a word. They allow us to move, set and clear single bits in registers or numbers that we specify.

Here we just make, after declare and initialize two variables in the extremes, is make an AND with two unsigned char variables, then bitwise them in opposite ways. All that rest is to wait for the overflow of both bytes and reset them again. Simple like this!

The result you can view in the gift above.

In the next lesson let’s make a Complex Lighting LEDS :)

And that’s it!

Thanks a lot! See you in the next episode.

Bye!

Related posts:

1º Episode — IO: Debut pic — Pic 18 Hello World \o/ — Just initiating a magic journey throughout Microchip’s best seller pastille

2º Episode — IO: Debut pic — Pic 18 Push & Blink an LED — Let’s Unveil IO’s PIC18 Capabilities

3º Episode — IO: Debut pic — PIC 18 Push & Debounce! — Treating buttons’ Debounce

4º Episode — IO: Debut pic — PIC 18 Lighting LEDs In a Row! — Nice Special Effect

5º Episode — IO: Debut pic — PIC 18 Chasing LEDs — The net result is that LEDs seem to be chasing each other

6º Episode — IO: Debut pic — PIC 18 Double Chasing— The LEDs chase each other in both directions

7º Episode — IO: Debut pic — PIC 18 Ambulance Light — Algorithm for ambulance-flashing-light

8º Episode — IO: Debut pic — PIC 18 Random Flashing — Generating a random number

9º Episode — IO: Debut pic — PIC 18 internal weak pull-ups — How to programming WPUR

10º Episode — IO: Debut pic — Button Library — How to use mikroC PRO for PIC library

11º Episode — IO: Debut pic — Up Down Counter — How to use mikroC PRO for PIC library

--

--

J3
Jungletronics

😎 Gilberto Oliveira Jr | 🖥️ Computer Engineer | 🐍 Python | 🧩 C | 💎 Rails | 🤖 AI & IoT | ✍️