Patrick Fitzgerald
Published

Mathematics on the Arduino Uno

If the Arduino is a computer then does it do mathematics? We are going to have one count and watch it in the simulator.

IntermediateProtip1 hour570

Things used in this project

Story

Read more

Code

math.c

C/C++
C language program for Arduino. PORTB counts from 0 to 255. You may have to rename your download to math.c. Same code used in project text.
// PORTB is an 8bit number at address 0x24
#define F_CPU 16000000
#include <avr/io.h>
#include <util/delay.h>
int main(void){   DDRB = 0xFF; 	// turn PORTB on
	    while(1){PORTB++;  	// increment PORTB
		  _delay_ms(100);	}}

Credits

Patrick Fitzgerald

Patrick Fitzgerald

100 projects • 28 followers

Comments