TB1BUZZER [Arduino ATmega2560]


Code

Project includes single file tb1led.ino which contains 2 functions: setup() and loop().

Function setup() is called once when a firmware starts. It configures serial port UART1 as 115200, 8N1. Then it prints greatings message to serial port and configure digital pins as output. 

Please see MINI-MAX Microcontroller Board Family Interchangeable Port Mapping for more information.

All program logic presented inside loop() function. This function is called in forever loop, so we just place here code which we want execute on each call. The logic of TB1LED example is very easy:

  • Turn on the buzzer on TB-1
  • wait 1ms
  • Turn off the buzzer on TB-1
  • wait 1ms

This caused a buzzing sound.

Toolkit:AVR Development System

Location:\bipom\devtools\Arduino\ATmega2560\Examples\tb1\tb1buzzer

Photos


TB-1 Training Board connected to MINI-MAX/AVR-C Board TB-1 Training Board connected to MINI-MAX/AVR-C Board
Terminal window in Micro-IDE when TB1LED example is running Terminal window in Micro-IDE when TB1LED example is running

Code Example


#include "tb1buzzer.h"


void setup() 
{ 
	Serial.begin(115200); 

  	// prints string with ending line break 

  	Serial.println("BiPOM Arduino"); 
  	Serial.println("TB1 Buzzer Example"); 
  
    pinMode(BUZZER_PIN, OUTPUT);      
} 

void loop() 
{ 
	// Turn on the buzzer on TB-1

	digitalWrite(BUZZER_PIN, LOW);
	delay(BUZZER_DELAY);

	// Turn off the buzzer on TB-1

	digitalWrite(BUZZER_PIN, HIGH);
	delay(BUZZER_DELAY);
}