Re: NEWBE with microcontrollers
Hi,
Its easy enough to do what you want, you can find a great deal of help in the tutorials listed below.
Be aware that many Pic output pins default to Analogue mode so you must set them to Digital for Led use.
If you want a led start up code in Pic assembly for the 628A just say.
Thanks for the response. I'll check out the tutorials.
I'm trying to write this without having someone write anything for me, because I'm forcing myself to figure it out.
I've been refreshing my memory on AND, OR, XOR functions, and trying to remember how to toggle a single bit. I know AND will allow me to turn a single bit on, but it's turning one off without affecting the rest that I'm missing.
- - - Updated - - -
Hahaha. I didn't catch the typo, and when I searched a bunch of different places for FPR, I was getting nothing.
- - - Updated - - -
So here's my basic section for controlling the PWM on the 6 segments that will chase:
Code C - [expand] |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
| // amber 1
if (pc < seg1)
// set bit for *rb1* to 1;
if (pc >= seg1)
// set bit for* rb1* to 0;
// amber 2
if (pc < seg2)
// set bit for *rb0* to 1;
if (pc >= seg2)
// set bit for *rb0* to 0;
// amber 3
if (pc < seg3)
// set bit for *ra5* to 1;
if (pc >= seg3)
// set bit for *ra5* to 0;
// amber 4
if (pc < seg4)
// set bit for *ra4* to 1;
if (pc >= seg4)
// set bit for *ra4* to 0;
// amber 5
if (pc < seg5)
// set bit for *ra3* to 1;
if (pc >= seg5)
// set bit for *ra3* to 0;
// amber 6
if (pc < seg6)
// set bit for *ra2* to 1;
if (pc >= seg6)
// set bit for *ra2* to 0; |
This is inside of a loop where pc is the 8 bit counter for the PWM. seg1, seg2, seg3, etc. are the PWM duty cycle for that sepcific segment (the segments will be set to 95% duty cycle as each illuminates, and then will fade slowly, so they will not all be running on the same duty cycle)
As I mentioned earlier, I'm sure I can simply define the 6 numbers that have the corresponding bit set, then just use the AND function to turn a bit on, but to turn it off, how would I write it?