AVR coding to Arduino coding (Sparkfun ClockIt kit)

Hi,

I am trying to replicate the functions of the alarm clock for the ClockIt kit on Sparfun using the arduino coding instead of AVR which is the code that comes installed is the firmware on the kit. Can anyone help translate the coding from AVR to arduino coding for this kit? The code is in the documents section at the bottom of this link: https://www.sparkfun.com/products/10930

Thank you in advance.

-Rivera

I can tell you how to make it compile okay but not if it will then work or not, hopefully it’s okay :slight_smile:

  1. Open the arduino ide and create a new sketch of the desired name

  2. Paste the contents of the .c source file from your link into the new arduino source, so that the source code from the .c is all that is in the new arduino sketch

  3. In the source code, find the “main()” method which is shown below :-

int main (void)
{
	ioinit(); //Boot up defaults
	
	while(1)
	{
		check_buttons(); //See if we need to set the time or snooze
		check_alarm(); //See if the current time is equal to the alarm time
	}
	
    return(0);
}

Rename the main() method to loop(), change the code shown above to be like the example below, you must also add the setup() method (as shown below):-

void setup()
{
}
void loop(void)
{
	ioinit(); //Boot up defaults
	
	while(1)
	{
		check_buttons(); //See if we need to set the time or snooze
		check_alarm(); //See if the current time is equal to the alarm time
	}
	
   // return(0);
}

OR: to develop this to use the arduino setup() method in a more normal way you should be able to do this:-

void setup()
{
	ioinit(); //Boot up defaults
}
void loop(void)
{
		check_buttons(); //See if we need to set the time or snooze
		check_alarm(); //See if the current time is equal to the alarm time
}