Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Syntax & Programs / Re: Making Stopwatch with Pushbutton & millis() on: July 31, 2010, 12:34:42 am
Wow thanks alot kitty, your code makes so much more sense to me
2  Forum 2005-2010 (read only) / Development / - 4 BIT LCD - on: September 21, 2010, 11:07:52 am
Hello guys, I am quite new to AVR and GCC and I am having a bit of trouble trying to get a LCD to work in 4 bit mode, I have been able to get it to work in 8 bit mode, but I think I am initializing it wrong, I have actually no clue whats wrong, I have been following this for the initialization
This may be an Arduino forum but someone must know some gcc ?

http://www.bipom.com/documents/appnotes/LCD%20Interfacing%20using%20HD44780%20Hitachi%20chipset%20compatible%20LCD.pdf

and here is my code, I know it looks bad but i will neaten it up when it works!
:
Code:



#include<util/delay.h>  
#include<avr/interrupt.h>  
#define DATA_DDR       DDRB            
#define DATA_PORT        PORTB
#define CONTROL_DDR              DDRD      
#define CONTROL_PORT        PORTD
#define Enable_Pin              6
#define RegSelect_Pin     4    
#define ReadWrite_Pin     5
#define Set_Enable                          CONTROL_PORT|=_BV(Enable_Pin)
#define Clear_Enable                         CONTROL_PORT&=~_BV(Enable_Pin)
#define Write_Lcd                            CONTROL_PORT&=~_BV(ReadWrite_Pin)
#define Read_Lcd                                 CONTROL_PORT|=_BV(ReadWrite_Pin)
#define Select_InstructionRegister       CONTROL_PORT&=~_BV(RegSelect_Pin) //Sets register select low
#define Select_DataRegister                CONTROL_PORT|=_BV(RegSelect_Pin)






int main(void)
{
_delay_ms(20);
Select_InstructionRegister;

PORTB = 0B0000;
    Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);
PORTB = 0B0011;
      Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);

_delay_ms(5);

PORTB = 0B0000;
    Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);
PORTB = 0B0011;
      Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);

_delay_us(160);

PORTB = 0B0000;
    Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);
PORTB = 0B0011;
      Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);

_delay_us(160);


PORTB = 0B0000;
    Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);
PORTB = 0B0010;
      Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);

_delay_us(160);

PORTB = 0B0011;
    Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);
PORTB = 0B1000;
      Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);

PORTB = 0B0011;
    Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);
PORTB = 0B1000;
      Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);

PORTB = 0B0001;
    Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);
PORTB = 0B0000;
      Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);


PORTB = 0B0000;
    Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);
PORTB = 0B0001;
      Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);

PORTB = 0B0000;
    Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);
PORTB = 0B0110;
      Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);


PORTB = 0B0000;
    Set_Enable;
      
      Clear_Enable;
      _delay_us(100);
PORTB = 0B1100;
      Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);


for(;;) // loop forever
{

Select_DataRegister;

PORTB = 0B0010;  
    Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);
PORTB = 0B1110;
      Set_Enable;
      _delay_us(100);
      Clear_Enable;
      _delay_us(100);




}
}


Any help appreciated...

P.S I have posted this on other forums if you have seen this post before, I just want to get the quickest and best reply.
3  Forum 2005-2010 (read only) / Development / Re: Arduino New Servo Controller on: July 31, 2010, 04:16:29 am
Well maybe I am, I have arduino 16 and I didnt know they upgraded the arduino servo library, I know that servo's dont need PWM, thats why i found it strange that the old servo library could only run on PWM pins so I wanted to create a way to do so, thanks for the help guys... much appreciated
4  Forum 2005-2010 (read only) / Development / Re: Arduino New Servo Controller on: July 30, 2010, 03:00:51 pm
I know that, im not that stupid smiley-razz, The existing one only works on PWM pins so i want to make one that works on all pins.
5  Forum 2005-2010 (read only) / Development / Arduino New Servo Controller on: July 30, 2010, 02:08:16 pm
Hey guys, I have an interesting problem for you, I have got some code here that I need help with:

 
Code:
int Servo1 = 13; // pin for servo
int myAngle;
int pulseWidth1;
void setup() {
pinMode(Servo1, OUTPUT);

}

void loop() {

Servo1Angel(0);

}

void Servo1Angel (int myAngle) {
pulseWidth1 = (myAngle * 11) + 500; // Converts angle to microseconds
digitalWrite(Servo1, HIGH); // Set servo high (turns it on)
delayMicroseconds(pulseWidth1); // Wait a very very small amount
digitalWrite(Servo1, LOW); // Set servo low (turns it off)
delay(20); // Typical Refresh cycle of servo (20 ms)
}

My aim is to make a servo library that works on any arduino pin because I do not like to be limited by PWM pins. So my problem is that , the code works but when ever I add a delay in the loops it obviously affects the other delays in the Servo1Angel therefore affecting the servo square wave I wanted to create, so is there another way ( other that using PWM) to replicate the result of that code and be able to use delays.

Any help appreciated smiley
6  Forum 2005-2010 (read only) / Troubleshooting / Re: Arduino doesn't feel like being programmed. on: July 18, 2010, 07:51:54 am
Reburn the bootloader and try again, maybe that will work, maybe the rx and tx are being bridged, thats why you can upload from avr studio, what surface are you uploading from?
7  Forum 2005-2010 (read only) / Troubleshooting / Re: MaxSerial quit uploading on: May 29, 2010, 01:10:17 am
Hi guys, I have got a max232 on a breadboard connected to my arduino Deulemonove which has an external power supply which is a usb 5v... If i bridge the rx tx coming from my max232 and go to serial monitor and type something it comes up. Everything seems to be working but I cant seem to upload code. I dont have auto reset but what i do is i click upload to board and wait 1 second then click the reset button. I have the rx tx leds coming from my serial port and what it does it : when i click the upload button the i click the reset the rx led flashes and then the tx led just come on and after 5 mins it gives me the :
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

any help would be appreciated
8  Forum 2005-2010 (read only) / Development / Re: Arduino serial with MAX232 or equivalent? on: June 03, 2010, 01:28:22 pm
How u get the silkscreen on the board, in ur design i see like a pologon on the bottom layer but it just print jaggered lines, how do i change it to fill in the whole thing... thanks in advance
9  Forum 2005-2010 (read only) / Interfacing / Re: I need advice: Building autonomous toy Car on: October 01, 2010, 04:09:25 pm
Why 18 ? I thought you only needed 6 for a hexapod ?
10  Forum 2005-2010 (read only) / Interfacing / Re: I need advice: Building autonomous toy Car on: October 01, 2010, 01:26:12 pm
Looks like someone has been watching Prototype this. smiley
11  Forum 2005-2010 (read only) / Interfacing / Re: I need advice: Building autonomous toy Car on: July 06, 2010, 02:19:58 pm
I like the idea to be honest, but I think you are trying to put too many functions in one robot. do you realy expect it to work first time without trial and error. What i suggest is that you play around with each individual sensor and post some code like how to detect an obsticla and we can write the rest of it for you. Like to go to a lighter spot you would say

if (leftlightval > rightlightval){
left()
}
or something
12  Forum 2005-2010 (read only) / Exhibition / Re: Clapper on: August 04, 2010, 09:14:12 am
I tried out your circuit and it doesnt seem to want to work for me smiley-sad... I think your circuit needs to be like this


                 5v
                    |
                    |----------|
                  _|   E       O mike
                 |_)--B------|
                    |  C
                    |
 analog 0-----*------ww------|i   ground
                             10k
Pages: [1]