NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Support Forum » dip_arithmetic project questions
August 09, 2010 by kle8309 |
Can anyone explain how does or why we use a integer16 (16 bits)lcd write function to write a uint8_t (8 bits). A different question but isn't it a bad idea to short the pin when connecting the switch to ground. It draws about 85mA of current when I measured it. Is there is safer way to do it. |
---|---|
August 09, 2010 by kle8309 |
int main() { // start up the LCD lcd_init(); lcd_home(); // Set the 6 pins to input mode - Two 3 bit numbers // turn on the internal resistors for the pins PORTC |= (1<<PC0); // turn on internal pull up resistor for PC0 PORTC |= (1<<PC1); // turn on internal pull up resistor for PC1 PORTC |= (1<<PC2); // turn on internal pull up resistor for PC2 PORTC |= (1<<PC3); // turn on internal pull up resistor for PC3 PORTC |= (1<<PC4); // turn on internal pull up resistor for PC6 PORTC |= (1<<PC5); // turn on internal pull up resistor for PC7 // declare the variables to represent each bit, of our two 3 bit numbers uint8_t a1; uint8_t a2; uint8_t a3; uint8_t b1; uint8_t b2; uint8_t b3; while(1) {
} return 0; } |
August 09, 2010 by hevans (NerdKits Staff) |
Hi kle8309, When you attempt to call a function that takes a 16 bit integer with an 8 bit integer the 8 bit integer is cast into a 16 bit integer when it gets passed to the function. Seeing as most of the time we use either 16 bit or 8 bit integers we just made one lcd_write_int16() function and use it for both. Hope that answers your question. Humberto |
August 10, 2010 by kle8309 |
Thanks Humberto! |
Please log in to post a reply.
Did you know that a thermometer can be made "faster" by using a bit of math? Learn more...
|