ELEKTOR FORUMS

Please log in to post a reply or subscribe / unsubscribe to topics

Topic: wait loop

Author Post

dirk_999

10 posts

Popping In
Popping In

Read post 09-04-2012 15:06

I plug the switch bord on portB.
I plug the led bord on portC.

I press switch B0 and I'm holding it down the entire time.

I download the following program in the µC.

trisb=0b11111111;
trisc=0b00000000;
portc=0b00000000;
delay_s(2);
while(portb&0b00000001); //waiting loop
portc=0b00000001;
while(1);

After 2 seconds the led C0 goes on. What is the reason for this?
I hoped that the led C0 would light up but only when I let the button B0 go.

Thanks in advance for your help

GeenBert

81 posts

Frequent Visitor
Frequent Visitor

Read post 10-04-2012 09:26

Did you connect the switchboard to the power?

dirk_999

10 posts

Popping In
Popping In

Read post 10-04-2012 15:35

thanks that was my stupid fault

GeenBert

81 posts

Frequent Visitor
Frequent Visitor

Read post 10-04-2012 16:41

Glad to hear that this solved your problem. Enjoy the course.

Please log in to post a reply or subscribe / unsubscribe to topics

Follow Elektor

      

Act now!

Package Deals

Elektor Bundles

Check our Package Deals and save money! Discounts up to 19% now available!

Price Slashed

Elektor OSPV

This Open Source People Vehicle is perfect for factory halls, warehouses, hospitals, colleges, schools etc.