Hey:
I a a new user to this forum (hi to all of you ) , so please forgive me if I am not posting this in the correct forum:
I am new to programing and this semester at uni we have a course where we are tought C.
My problem is the following: I have writen a function that is supposed to turn all the values in an array to 0 and then the microcontroller should print it on an LCD. I am using Atmel studio 7, the microcontroller is an Atmel328P and the setup is the following:
Shared album - Alvaro Soler Verdu - Google Photos
And this is my code. Thanks to everybody that reads or answeres!
Code:
#define F_CPU 16E6
#include <avr/io.h>
#include <stdio.h>
#include <util/delay.h>
#include "i2cmaster.h"
#include "ds1621.h"
#include "lcd.h"
void printnumbers1(void);
void reset_0(void);
int array[8]={1,0,0,1,1,0,0,0};
int main(void)
{
lcd_init();
DDRD = 0xFF; //I/O board:PD4...7 as outputs, for LEDs
DDRC = 0xF0; //I/O board PC0...3 as inputs, for buttons
PORTC = 0x3F; // Enable internal pull at PC0..3 inputs
PORTD = 0x00; // Set output LEDs to off
while(1)
{
printnumbers1();
reset();
}
}
void printnumbers1(void)
{
int i=0;
for (i=7; i>=0; i--) //the function that prints array
{
lcd_gotoxy(1,i+1);
printf("%d", array[i]);
}
}
void reset_0(void)
{ int u;
if (PINC==0b00001110)
{
for (u=7;u>=0;u--)
{
array[u]=0;
}
_delay_ms(300);
}
}