Showing posts with label atmel studio. Show all posts
Showing posts with label atmel studio. Show all posts

Monday, November 23, 2015

Getting Started with the Atmel Xplained Mini with the ATmega168PB MCU

In this video we give you an overview of the Atmel Xplained Mini which is a development board for the ATmega168PB microcontroller. In the video we cover how to load a simple "Blink" program onto the Xplained Mini with Atmel Studio and how the development board is compatible with Arduino Shields. The video is presented from the standpoint of an Arduino user. You can access the code from the video below.



//**************************Atmel Studio Code****************************
/*
 * ATmega168PB Example.c
 *
 * Created: 11/21/2015 4:59:24 PM
 * Author : ForceTronics
 */ 

#define F_CPU 16000000UL //Set the clock frequency
#include <avr/io.h> //call IO library
#include <util/delay.h> //call delay library

int main(void)
{
DDRB |= (1<<DDB5); //Set Port B 5 or PB5 or PCINT5 or pin 17 to output (1 is output and 0 is input)
while(1)
{
/*
PORTB |= (1<<PORTB5);    //Set PB5 to 1 which is high (LED on)
_delay_ms(1000);        //Delay for 1000ms or 1 sec
PORTB &= ~(1<<PORTB5);    //Set PB5 to 0 which is low (LED off)
_delay_ms(1000);        //Delay for 1000ms or 1 sec
*/
PINB |= (1<<PINB5);
_delay_ms(1000);        //Delay for 1000ms or 1 sec
}
}



Saturday, September 19, 2015

Debugging with the Arduino Zero

In this video we look at how to do debugging with the Arduino Zero. The Arduino Zero has a lot of great capabilities and features. One of those great features is it has a built-in hardware debugger. In this video we will look at how to use the debugger and the software you need to go with it.




//***************Arduino Code from Video**********************************
/*
This code was used for a tutorial video on the ForceTronics YouTube Channel that showed
how to do debugging with the Arduino Zero and Atmel Studio. This code is free and open
for anybody to use or modify
 */
int ranNum; //global variable to hold random number

void setup() {
  randomSeed(analogRead(A0)); //seed value for random number generator
  pinMode(13, OUTPUT); // initialize digital pin 13 as an output.
}

void loop() {
  
  ranNum = random(0,100);   //generate a random number between zero and 100
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}