Sep 15, 2015 at 8:43pm UTC
expected intializer before void??
#define KeypadDirectionRegister DDRD
#define KeypadPortControl PORTD
#define KeypadPortValue PIND
#define LEDDirectionRegister DDRB
#define LEDPort PORTB
#define F_CPU 16000000UL
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <util/delay.h>
#include <avr/io.h>
void KeypadScan()
void KeypadScan()
{
if (KeypadPortValue == 0b11110000) return
_delay_ms(50);
uint8_t keypressCode = KeypadPortValue;
KeypadDirectionRegister ^= 0b11111111;
KeypadPortControl ^= 0b11111111;
asm volatile("nop");
asm volatile("nop");
keyPressCode |= keypadPortValue;
unit8_t blinkDuration = 0;
if (keyPressCode == 0b11101110) blinkDuration =1;
if (keyPressCode == 0b11011110) blinkDuration =2;
if (keyPressCode == 0b10111110) blinkDuration =3;
if (keyPressCode == 0b11101110) blinkDuration =4;
if (keyPressCode == 0b11101101) blinkDuration =5;
if (keyPressCode == 0b11011101) blinkDuration =6;
if (keyPressCode == 0b10111101) blinkDuration =7;
if (keyPressCode == 0b11111101) blinkDuration =8;
if (keyPressCode == 0b11101011) blinkDuration =9;
if (keyPressCode == 0b11011011) blinkDuration =10;
if (keyPressCode == 0b10111011) blinkDuration =11;
if (keyPressCode == 0b01111011) blinkDuration =12;
if (keyPressCode == 0b11100111) blinkDuration =13;
if (keyPressCode == 0b11010111) blinkDuration =14;
if (keyPressCode == 0b10110111) blinkDuration =15;
if (keyPressCode == 0b01110111) blinkDuration =16;
if (keyPressCode <ob11111111)
{
for(int i;i<blinkDuration;i++)
{
_delay_ms(100);
LEDPort ^= 1<<PINBO;
_delay_ms(100);
LEDPort ^= 1<<PINBO;
}
}
}
int main(void)
{
LEDDirectionRegister = 0b00000001;
keypadDirectionRegister = 0b00001111;
keypadPortControl = 0b11110000;
while(1)
{
keypadScan();
}
}
Last edited on Sep 15, 2015 at 8:43pm UTC
Sep 15, 2015 at 8:50pm UTC
Rule of thumb. Always check for completed brackets, braces, and parentheses. Also check for semicolons, as you might see in your prototype of void KeypadScan()