Jonny Blanch.webs.com

games computers arduino

Arduino Page 1

 Here you will find some stuff for the Arduino Duemilove!

 This page has the am transmitter and lcd setup

Just keep scrolling down

Please Take note that I use a protoshield from adafruit

 

First Project: AM Arduino Morse Code Transmitter

Copy the code below and up load it to the I/O Board then put some kind of Antenna into PIN 8...PIN 8!!!! Then tune to AM 1337kHz. Optional:LED in pin 13 to see what is broadcasting,also a protoshield to add multiple antenna's.

Lol that code will do morse code saying "I like ice cream"

*********THE CODE****************************************************

//start of code
//WWW.JONNYBLANCH.WEBS.COM
long millisAtStart=0;
long millisAtEnd=0;

const long period_broadcast=8; //period of shortest broadcast (256 port changes)

#define LENGTH_DIT 64
//number of period_broadcasts in one 'dit',
//all other lengths are scaled from this
//Broadcasts on 1337 kHz

const int length_dit=LENGTH_DIT;//number of periods for dit
const int pause_dit=LENGTH_DIT;//pause after dit
const int length_dah=3*LENGTH_DIT;//number of persots for dah
const int pause_dah=LENGTH_DIT;//pause after dah
const int length_pause=7*LENGTH_DIT;//pause between words

void dit(void);
void dah(void);
void pause(void);
void broadcast(int N_cycles);
void dontbroadcast(int N_cycles);

// ### INC ### Increment Register (reg = reg + 1)
#define ASM_INC(reg) asm volatile ("inc %0" : "=r" (reg) : "0" (reg))

void setup()
{

  Serial.begin(9600);
  DDRB=0xFF;  //Port B all outputs
  //Do one dit to determine approximate frequency
  millisAtStart=millis();
  dit();
  millisAtEnd=millis();
  Serial.print(millisAtEnd-millisAtStart);
  Serial.print(" ");
  Serial.print((length_dit+pause_dit)*period_broadcast*256/(millisAtEnd-millisAtStart)/2);
  Serial.print("kHz ");
  Serial.println();
}

void loop()
{
  dit();
  dit();
  delay(500);
  dit();
  dah();
  dit();
  dit();
  delay(250);
  dit();
  dit();
  delay(250);
  dah();
  dit();
  dah();
  delay(250);
  dit();
  delay(500);
  dit();
  dit();
  delay(250);
  dah();
  dit();
  dah();
  dit();
  delay(250);
  dit();
  delay(500);
  dah();
  dit();
  dah();
  dit();
  delay(250);
  dit();
  dah();
  dit();
  delay(250);
  dit();
  delay(250);
  dit();
  dah();
  delay(250);
  dah();
  dah();
  delay(2000);

}

void dit(void)
{
  for(int i=0;ifor(int i=0;ivoid dah(void)
{
  for(int i=0;ifor(int i=0;ivoid pause(void)
{
  for(int i=0;ivoid broadcast(int N_cycles)
{
  unsigned int portvalue;
  for (int i=0;ido
    {
	PORTB=portvalue;
	ASM_INC(portvalue);
    }
    while(portvalue<255);
  }
}

void dontbroadcast(int N_cycles)
{
  unsigned int portvalue;
  PORTB=0x00;
  for (int i=0;ido
    {
	ASM_INC(portvalue);
	//add some assembly No OPerations to keep timing the same
	asm volatile ("NOP");
    }
    while(portvalue<255);
  }
}
//end of code

 

Second Project:LCD Setup

Here is how to set up the LCD

Assuming you have a standard 16x2 HD44780 LCD

Look on the back of the LCD to find which is pin 1 and which is pin 16

!!!Sample Code toward bottom!!!

~Now the Connections below

***LCD Pin TO Arduino Digital Pin or power**

Pin 1 TO Ground

Pin 2 TO 5v

Pin 3 TO the potentiometer

Pin 4 TO Digital Pin 7

Pin 5 TO Ground

Pin 6 TO Digital Pin 8

Pins 7-10 not being used

Pin 11 TO Digital Pin 9

Pin 12 TO Digital Pin 10

Pin 13 TO Digital Pin 11

Pin 14 TO Digital Pin 12

Pin 15 TO 5v Positive

Pin 16 TO Negitive

and finally put a ground to the pententiometer

    Pictures of mine-

***CODE*********************************************************

 


 //Code Modified By www.jonnyblanch.webs.com
 
 //Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 //library works with all LCD displays that are compatible with the 
 //Hitachi HD44780 driver. There are many of them out there, and you
 //can usually tell them by the 16-pin interface.
 
 //This sketch prints "Hello World!" to the LCD and uses the
 //scrollDisplayLeft() and scrollDisplayRight() methods to scroll
 //the text.
 
  

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
// Take note of the pin numbers
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
  // set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);
  //lcd.setCursor(0,7);
  // Print a message to the LCD.
  lcd.print("Hello, World! I am working now!!!");
  delay(1000);
}

void loop() {
  // scroll 18 positions (string length) to the left 
  // to move it offscreen left:
  for (int positionCounter = 0; positionCounter < 18; positionCounter++) {
    // scroll one position left:
    lcd.scrollDisplayLeft(); 
    // wait a bit:
    delay(500);
  }

  // scroll 20 positions (string length + display length) to the right
  // to move it offscreen right:
  for (int positionCounter = 0; positionCounter < 20; positionCounter++) {
    // scroll one position right:
    lcd.scrollDisplayRight(); 
    // wait a bit:
    delay(150);
  }
  
    // scroll 16 positions (display length + string length) to the left
    // to move it back to center:
  for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
    // scroll one position left:
    lcd.scrollDisplayLeft(); 
    // wait a bit:
    delay(150);
  }
  
  // delay at the end of the full loop:
  delay(1000);

}