May 21, 2012, 01:55:48 PM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
:
Home
Help
Search
Login
Register
International Electronics and Technology Forum
>
Digital Electronics
>
Microcontrollers
>
Logical Operator C needed?
Pages: [
1
]
« previous
next »
Print
Author
Topic: Logical Operator C needed? (Read 436 times)
Frisky
Newbie
Posts: 1
Logical Operator C needed?
«
on:
May 14, 2011, 07:09:19 PM »
I am trying to write a program for a PIC Microcontroller.
I have to generate the binary-equivalent of the following decimal numbers:
119, 76, 14, 55 & 99.
So, by writing the code below I can generate the output for 119- several LEDs blink continuosly.
Now, if I want to generate the same effect for the other decimal numbers and add all that in the same program what operator should I use?
void main() {
TRISB=0; //MAKING PORT B OUTPUT
while (1) {
PORTB = 0x77; //Make port B high
delay_100ms; //maintain portb as high for 100ms
PORTB = 0x00; //Make port b low
delay_100ms; //maintain port b as low for 100ms
}
Logged
justme
Newbie
Posts: 8
Re: Logical Operator C needed?
«
Reply #1 on:
May 14, 2011, 08:07:57 PM »
simply add them to the code. no need to even convert to hex:
void main() {
TRISB=0; //MAKING PORT B OUTPUT
while (1) {
PORTB = 0x77; //Make port B high
delay_100ms; //maintain portb as high for 100ms
PORTB = 76; //Make port B high
delay_100ms; //maintain portb as high for 100ms
PORTB = 14; //Make port B high
delay_100ms; //maintain portb as high for 100ms
//etc...
PORTB = 0x00; //Make port b low
delay_100ms; //maintain port b as low for 100ms
}
Logged
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Electrotechlab Primer
-----------------------------
=> About Electrotechlab
=> Electronics News
=> Consumer Electronics and Gadgets
=> General Technology
=> Computers and Internet
-----------------------------
Analog and Mixed Signal
-----------------------------
=> Electricity and Analog Electronics
=> Signal Conversion and Signal Processing
=> Industrial Electronics
-----------------------------
Digital Electronics
-----------------------------
=> Combination Logic Circuits
=> Microcontrollers
=> PLD SPLD GAL CPLD FPGA
-----------------------------
Specialization
-----------------------------
=> Wire Communications
=> Wireless Communication
=> Hi Fidelity Audio and Video
=> Mechatronics and Robotics
=> Amateur Ham Radio
-----------------------------
Electrical Electronics Repair
-----------------------------
=> Test Equipment and Instrumentation
=> General Electrical and Electronics Repair
=> Personal Computer and Peripherals
-----------------------------
Resources
-----------------------------
=> Computer Programming
=> PCB Design
=> Datasheets Manuals Ebooks and Links
=> Electronic Projects Design and Ideas
-----------------------------
General Forum
-----------------------------
=> Anything Under The Sun
=> Arts Culture and Lifestyle
=> Sports Games and Entertainment
=> General Science
=> Health and Medicine
Loading...