Show Posts
Pages: 1 2 [3] 4 5 ... 17
31  Forum 2005-2010 (read only) / Interfacing / Re: Stop-Print on: May 31, 2009, 02:42:53 pm
I was just looking for a STOP function. or something like that
32  Forum 2005-2010 (read only) / Interfacing / Re: Stop-Print on: May 31, 2009, 01:59:41 pm
int ledPin = 13; // choose the pin for the LED
int inPin = 2;   // choose the input pin (for a pushbutton)
int val = 0;     // variable for reading the pin status

void setup() {
  pinMode(ledPin, OUTPUT);  // declare LED as output
  pinMode(inPin, INPUT);    // declare pushbutton as input
  Serial.begin(115200);      // open the serial port at 9600 bps:    
}

void loop(){
  val = digitalRead(inPin);  // read input value
  if (val == HIGH) {         // check if the input is HIGH (button released)
    Serial.print("LOW");
   digitalWrite(ledPin, LOW); // turn LED OFF
   return;
  } else {
    digitalWrite(ledPin, HIGH);
    Serial.print("HIGH");  // turn LED ON
    return;
  }
  delayMicroseconds(1);
}
33  Forum 2005-2010 (read only) / Interfacing / Stop-Print on: May 31, 2009, 01:59:34 pm
I have this program here, which when i press the button it will turn off the led and print HIGH or LOW in the serial port. But it prints HIGH and LOW multiple times. HOw do i have it so for every press it only prints HIGH or LOW once? THanks
34  Forum 2005-2010 (read only) / Interfacing / Re: Tv be gona with arduino on: May 18, 2009, 07:12:59 pm
 { 924,   464 },
  {  58,    57 },
  {  58,    57 },
  {  58,    57 },
  {  58,    57 },
  {  58,    57 },
  {  58,    57 },
  {  58,   173 },
  {  58,    57 },
  {  58,   173 },
  {  58,   173 },
  {  58,   173 },
  {  58,   173 },
  {  58,   173 },
  {  58,   173 },
  {  58,    57 },
  {  58,   173 },
  {  58,    57 },
  {  58,   173 },
  {  58,    57 },
  {  58,    57 },
  {  58,   173 },
  {  58,    57 },
  {  58,    57 },
  {  58,    57 },
  {  58,   173 },
  {  58,    57 },
  {  58,   173 },
  {  58,   173 },
  {  58,    57 },
  {  58,   173 },
  {  58,   173 },
  {  58,   173 },
  {  58,  4054 },
  { 926,   230 },
  {  58,  9880 },
  { 926,   230 },
  {  58,     0 },
  { ( ( (8000000.0 / 34800.0) / 2.0 ) - 1.0),   0 },   // Code 005 -- Philips, Grundig, Pye
  {  92,    92 },
  { 184,    92 },
  {  92,    92 },
  {  92,    92 },
  {  92,    92 },
  {  92,    92 },
  {  92,    92 },
  {  92,    92 },
  {  92,   184 },
  {  92,    92 },
  { 184,    92 },
  {  92,  9216 },
  {  92,    92 },
  { 184,    92 },
  {  92,    92 },
  {  92,    92 },
  {  92,    92 },
  {  92,    92 },
  {  92,    92 },
  {  92,    92 },
  {  92,   184 },
  {  92,    92 },
  { 184,    92 },
  {  92,     0 },
  { ( ( (8000000.0 / 37470.0) / 2.0 ) - 1.0),   0 },   // Code 006 -- Samsung
  { 462,   476 },
  {  53,   175 },
  {  53,   175 },
  {  53,   175 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,   175 },
  {  53,   175 },
  {  53,   175 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,   175 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,   175 },
  {  53,    62 },
  {  53,   175 },
  {  53,   175 },
  {  53,   175 },
  {  53,   175 },
  {  53,   175 },
  {  53,   175 },
  {  53,  4661 },
  { 464,   476 },
  {  53,   175 },
  {  53,   175 },
  {  53,   175 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,   175 },
  {  53,   175 },
  {  53,   175 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,   175 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,    62 },
  {  53,   175 },
  {  53,    62 },
  {  53,   175 },
  {  53,   175 },
  {  53,   175 },
  {  53,   175 },
  {  53,   175 },
  {  53,   175 },
  {  53,     0 },
//  { ( ( (8000000.0 / 38200.0) / 2.0 ) - 1.0),   0 },   // Code 007 -- Zenith
//  {  52,    49 },
//  {  52,   419 },
//  {  52,   522 },
//  {  52,    49 },
//  {  52,   419 },
//  {  52,    49 },
//  {  52,   419 },
//  {  52,   522 },
//  {  52,    49 },
//  {  52,   419 },
//  {  52,   522 },
//  {  52,    49 },
//  {  52,   419 },
//  {  52,   522 },
//  {  52,   522 },
//  {  52,    49 },
//  {  52, 12433 },
//  {  52,    49 },
//  {  52,   419 },
//  {  52,   522 },
//  {  52,    49 },
//  {  52,   419 },
//  {  52,    49 },
//  {  52,   419 },
//  {  52,   522 },
//  {  52,    49 },
//  {  52,   419 },
//  {  52,   522 },
//  {  52,    49 },
//  {  52,   419 },
//  {  52,   522 },
//  {  52,   522 },
//  {  52,    49 },
//  {  52,     0 },
  {   0,     0 }
};

// This function delays the specified number of 10 microseconds
void delay_ten_us(unsigned long int us) {
  unsigned long int timer;
  const unsigned long int DelayCount=6;  // this value was determined by trial and error

  while (us != 0) {
    // Toggling PD0 is done here to force the compiler to do this loop, rather than optimize it away
    for (timer=0; timer <= DelayCount; timer++) {PIND |= 0b0000001;};
    us--;
  }
}


// This function quickly pulses the visible LED (connected to PB0, pin 12)
void quickflashLED( void ) {
  // pulse LED at PB0 on for 30ms
  PORTB |= 0b00000001;          // turn on LED at PB0
  delay_ten_us(3000);           // 30 millisec delay
  PORTB &= 0b11111110;          // turn off LED at PB0
}


// This function quickly pulses the visible LED (connected to PB0, pin 12) 4 times
void quickflashLED4x( void ) {
  quickflashLED();
  delay_ten_us(15000);        // 150 millisec delay
  quickflashLED();
35  Forum 2005-2010 (read only) / Interfacing / Re: Tv be gona with arduino on: May 18, 2009, 07:12:48 pm
Sorry the code got split


#include <avr/io.h>             // this contains all the IO port definitions
#include <avr/interrupt.h>      // definitions for interrupts
#include <avr/sleep.h>          // definitions for power-down modes
#include <avr/pgmspace.h>       // definitions or keeping constants in program memory


// table of POWER codes
struct codeElement {
  unsigned int onTime;   // duration of "On" time
  unsigned int offTime;  // duration of "Off" time
} const powerTab[] PROGMEM = {
  { ( ( (8000000.0 / 37520.0) / 2.0 ) - 1.0),   0 },   // Code 000 -- Sony, Baur and a few others
  { 245,    60 },
  { 123,    60 },
  {  61,    60 },
  { 123,    60 },
  {  61,    60 },
  { 123,    60 },
  {  61,    60 },
  {  61,    60 },
  { 123,    60 },
  {  61,    60 },
  {  61,    60 },
  {  61,    60 },
  {  61,  2758 },
  { 246,    60 },
  { 123,    60 },
  {  61,    60 },
  { 123,    60 },
  {  61,    60 },
  { 123,    60 },
  {  61,    60 },
  {  61,    60 },
  { 123,    60 },
  {  61,    60 },
  {  61,    60 },
  {  61,    60 },
  {  61,     0 },
  { ( ( (8000000.0 / 55600.0) / 2.0 ) - 1.0),   0 },   // Code 001 -- Proscan, RCA and a few others
  { 411,   410 },
  {  52,   205 },
  {  52,   205 },
  {  52,   205 },
  {  52,   205 },
  {  52,   102 },
  {  52,   102 },
  {  52,   205 },
  {  52,   102 },
  {  52,   205 },
  {  52,   102 },
  {  52,   205 },
  {  52,   102 },
  {  52,   102 },
  {  52,   102 },
  {  52,   102 },
  {  52,   102 },
  {  52,   205 },
  {  52,   205 },
  {  52,   102 },
  {  52,   205 },
  {  52,   102 },
  {  52,   205 },
  {  52,   102 },
  {  52,   205 },
  {  52,   821 },
  { 411,   410 },
  {  52,   205 },
  {  52,   205 },
  {  52,   205 },
  {  52,   205 },
  {  52,   102 },
  {  52,   102 },
  {  52,   205 },
  {  52,   102 },
  {  52,   205 },
  {  52,   102 },
  {  52,   205 },
  {  52,   102 },
  {  52,   102 },
  {  52,   102 },
  {  52,   102 },
  {  52,   102 },
  {  52,   205 },
  {  52,   205 },
  {  52,   102 },
  {  52,   205 },
  {  52,   102 },
  {  52,   205 },
  {  52,   102 },
  {  52,   205 },
  {  52,     0 },
  { ( ( (8000000.0 / 36130.0) / 2.0 ) - 1.0),   0 },   // Code 002 -- Panasonic
  { 358,   179 },
  {  44,    45 },
  {  44,   135 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,   135 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,   135 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,   135 },
  {  44,    45 },
  {  44,   135 },
  {  44,   135 },
  {  44,   135 },
  {  44,   135 },
  {  44,    45 },
  {  44,    45 },
  {  44,   135 },
  {  44,    45 },
  {  44,   135 },
  {  44,   135 },
  {  44,   135 },
  {  44,   135 },
  {  44,    45 },
  {  44,   135 },
  {  44,  7720 },
  { 358,   180 },
  {  44,    45 },
  {  44,   135 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,   135 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,   135 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,   135 },
  {  44,    45 },
  {  44,   135 },
  {  44,   135 },
  {  44,   135 },
  {  44,   135 },
  {  44,    45 },
  {  44,    45 },
  {  44,   135 },
  {  44,    45 },
  {  44,   135 },
  {  44,   135 },
  {  44,   135 },
  {  44,   135 },
  {  44,    45 },
  {  44,   135 },
  {  44,     0 },
  { ( ( (8000000.0 / 37470.0) / 2.0 ) - 1.0),   0 },   // Code 003 -- Sharp
  {  28,   189 },
  {  29,    81 },
  {  29,    81 },
  {  29,    81 },
  {  29,    81 },
  {  29,    81 },
  {  29,   189 },
  {  29,   189 },
  {  29,    81 },
  {  29,   189 },
  {  29,    81 },
  {  29,    81 },
  {  29,    81 },
  {  29,   189 },
  {  29,    81 },
  {  29,  4670 },
  {  29,   189 },
  {  29,    81 },
  {  29,    81 },
  {  29,    81 },
  {  29,    81 },
  {  29,   189 },
  {  29,    81 },
  {  29,    81 },
  {  29,   189 },
  {  29,    81 },
  {  29,   189 },
  {  29,   189 },
  {  29,   189 },
  {  29,    81 },
  {  29,   189 },
  {  29,  4670 },
  {  29,   189 },
  {  29,    81 },
  {  29,    81 },
  {  29,    81 },
  {  29,    81 },
  {  29,    81 },
  {  29,   189 },
  {  29,   189 },
  {  29,    81 },
  {  29,   189 },
  {  29,    81 },
  {  29,    81 },
  {  29,    81 },
  {  29,   189 },
  {  29,    81 },
  {  29,  4670 },
  {  29,   189 },
  {  29,    81 },
  {  29,    81 },
  {  29,    81 },
  {  29,    81 },
  {  29,   189 },
  {  29,    81 },
  {  29,    81 },
  {  29,   189 },
  {  29,    81 },
  {  29,   189 },
  {  29,   189 },
  {  29,   189 },
  {  29,    81 },
  {  29,   189 },
  {  29,     0 },
  { ( ( (8000000.0 / 37470.0) / 2.0 ) - 1.0),   0 },   // Code 004 -- Toshiba, Apex
36  Forum 2005-2010 (read only) / Interfacing / Tv be gona with arduino on: May 18, 2009, 07:09:51 pm
Does anyone have this code written in "arduino language" it is for the tv be gone... thanks

/*
TV-B-Gone
Firmware
for use with ATtiny2313
Chaos Communications Camp 2007
Mitch Altman
31-Jul-07

Distributed under Creative Commons 2.5 -- Attib & Share Alike
*/


/*
Ladyada has a great website about the MiniPOV kit, from which this project was hacked:
http://ladyada.net/make/minipov3/index.html
Her website also has a user forum, where people can ask and answer questions by people building
various projects, including this one:
http://www.ladyada.net/forums/
(Click on the link for MiniPOV).
*/


#include <avr/io.h>             // this contains all the IO port definitions
#include <avr/interrupt.h>      // definitions for interrupts
#include <avr/sleep.h>          // definitions for power-down modes
#include <avr/pgmspace.h>       // definitions or keeping constants in program memory


/*
This project transmits a bunch of TV POWER codes, one right after the other,
with a pause in between each.  (To have a visible indication that it is
transmitting, it also pulses a Red  LED once each time a POWER code is
transmitted.)  That is all TV-B-Gone does.  The tricky part of TV-B-Gone
was collecting all of the POWER codes, and getting rid of the duplicates and
near-duplicates (because if there is a duplicate, then one POEWR code will
turn a TV off, and the duplicate will turn it on again (which we certainly
do not want).  I have compiled the top-40 most popular codes with the
duplicates eliminated, both for North America (which is the same as Asia, as
far as POWER codes are concerned -- even though much of Asia USES PAL video)
and for Europe (which works for Australia, New Zealand, the Middle East, and
other parts of the world that use PAL video).

Using the MiniPOV for this project presents a limitation, based on the size of
the Atmel ATtiny2313 internal flash memory, which is 2KB.  With 2KB we can only
fit about 7 POWER codes into the firmware's database of POWER codes.  If you
would like to make a TV-B-Gone with all 40 codes, then they should all fit into
another Atmel chip with 8KB of flash, such as ATtiny85.

This version of the firmware has the most popular 7 POWER codes for North America
(which is how many codes fit into the ATtiny2313 2KB flash memory).
*/


/*
This project is a good example of how to use the AVR chip timers.
*/


/*
The hardware for this project is very simple:
     ATtiny2313 has 20 pins:
       pin 1   connects to serial port programming circuitry
       pin 4   one pin of ceramic resonator
       pin 5   one pin of ceramic resonator
       pin 10  ground
       pin 12  PB0 - visible LED
       pin 14  OC0A - IR emitter, through a 2N3904 driver (with 120 ohm base resistor)
       pin 17  connects to serial port programming circuitry
       pin 18  connects to serial port programming circuitry
       pin 19  connects to serial port programming circuitry
       pin 20  +3v
    All other pins are unused

    This firmware requires that the clock frequency of the ATtiny
      is the default that it is shipped with:  8.0MHz

    IMPORTANT:  to use the ceramic resonator, you must perform the following:
                    make burn-fuse_cr
*/


/*
The C compiler creates code that will transfer all constants into RAM when the microcontroller
resets.  Since this firmware has a table (powerTab) that is too large to transfer into RAM,
the C compiler needs to be told to keep it in program memory space.  This is accomplished by
the macro PROGMEM (this is used, below, in the definition for the powerTab).  Since the
C compiler assumes that constants are in RAM, rather than in program memory, when accessing
the powerTab, we need to use the pgm_read_word() macro, and we need
to use the powerTab as an address, i.e., precede it with "&".  For example, to access
powerTab[3].onTime, which is a word, this is how to do it:
     pgm_read_word( &powerTab[3].onTime );
And to access powerTab[3].offTime, which is also a word, this is how to do it:
     pgm_read_word( &powerTab[3].offTime );
*/



/*
The following POWER code table consists of any number of POWER codes that will fit into the 2k flash ROM.
Each POWER code consists of any number of codeElements, each of which consists of an onTime
and an offTime (both onTime and offTime are expressed as the number of 10 microseconds -- for
example, 4110 microseconds would be entered as 411).  The onTime is a length of time that the
IR emitter is being pulsed with the carrier frequency (usually about 40KHz).  The offTime is
a length of time that the IR emitter is not emitting any IR.  The first codeElement of each
POWER code is actually a fake one:  the onTime contains the value to store in the compare
register for Timer 0 (called OCR0A), and the offTime is ignored -- see more info on this in
the next paragraph.  The last codeElement of each POWER code in the table is signified by
making its offTime = 0.  To signify the last POWER code in the table, the last POWER code in
the table must be followed by a codeElement with onTime = 0 (the offTime is ignored).

As stated above, the carrier frequency for each POWER code is determined by the value for
onTime in the POWER code's first codeElement.  This value is derived from the following
equation, given in the datasheet for the ATtiny2313:
     Output frequency = Fclk / (2 * Prescale * (1 + OCR1A) ) = 8,000,000 / (2 * (1 + OCR0A) )
So, given a desired carrier frequency, with the ATtiny2313 Fclk at 8.0Mhz, we determine OCR0A
by the following equation:
     OCR0A = ( ( (8,000,000.0 / carrierFrequency) / 2.0 ) - 1.0)
Where the carrierFrequency is stated in Hz (with at least one decimal place at the end).
Since all of these values are constants, we will let the C compiler calculate this value in
powerTab (using floating point by using a decimal point with all of the numbers).


There is a delay of 205 milliseconds after each POWER code is transmitted (whenever offTime = 0).
This delay is necessary so that a TV receiving the wrong POWER code will have time to reset itself
before receiving the next POWER code (which might be the correct one for it).
*/


// table of POWER codes
struct codeElement {
  unsigned int onTime;   // duration of "On" time
  unsigned int offTime;  // duration of "Off" time
} const powerTab[] PROGMEM = {
  { ( ( (8000000.0 / 37520.0) / 2.0 ) - 1.0),   0 },   // Code 000 -- Sony, Baur and a few others
  { 245,    60 },
  { 123,    60 },
  {  61,    60 },
  { 123,    60 },
  {  61,    60 },
  { 123,    60 },
  {  61,    60 },
  {  61,    60 },
  { 123,    60 },
  {  61,    60 },
  {  61,    60 },
  {  61,    60 },
  {  61,  2758 },
  { 246,    60 },
  { 123,    60 },
  {  61,    60 },
  { 123,    60 },
  {  61,    60 },
  { 123,    60 },
  {  61,    60 },
  {  61,    60 },
  { 123,    60 },
  {  61,    60 },
  {  61,    60 },
  {  61,    60 },
  {  61,     0 },
  { ( ( (8000000.0 / 55600.0) / 2.0 ) - 1.0),   0 },   // Code 001 -- Proscan, RCA and a few others
  { 411,   410 },
  {  52,   205 },
  {  52,   205 },
  {  52,   205 },
  {  52,   205 },
  {  52,   102 },
  {  52,   102 },
  {  52,   205 },
  {  52,   102 },
  {  52,   205 },
  {  52,   102 },
  {  52,   205 },
  {  52,   102 },
  {  52,   102 },
  {  52,   102 },
  {  52,   102 },
  {  52,   102 },
  {  52,   205 },
  {  52,   205 },
  {  52,   102 },
  {  52,   205 },
  {  52,   102 },
  {  52,   205 },
  {  52,   102 },
  {  52,   205 },
  {  52,   821 },
  { 411,   410 },
  {  52,   205 },
  {  52,   205 },
  {  52,   205 },
  {  52,   205 },
  {  52,   102 },
  {  52,   102 },
  {  52,   205 },
  {  52,   102 },
  {  52,   205 },
  {  52,   102 },
  {  52,   205 },
  {  52,   102 },
  {  52,   102 },
  {  52,   102 },
  {  52,   102 },
  {  52,   102 },
  {  52,   205 },
  {  52,   205 },
  {  52,   102 },
  {  52,   205 },
  {  52,   102 },
  {  52,   205 },
  {  52,   102 },
  {  52,   205 },
  {  52,     0 },
  { ( ( (8000000.0 / 36130.0) / 2.0 ) - 1.0),   0 },   // Code 002 -- Panasonic
  { 358,   179 },
  {  44,    45 },
  {  44,   135 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,   135 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,   135 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,   135 },
  {  44,    45 },
  {  44,   135 },
  {  44,   135 },
  {  44,   135 },
  {  44,   135 },
  {  44,    45 },
  {  44,    45 },
  {  44,   135 },
  {  44,    45 },
  {  44,   135 },
  {  44,   135 },
  {  44,   135 },
  {  44,   135 },
  {  44,    45 },
  {  44,   135 },
  {  44,  7720 },
  { 358,   180 },
  {  44,    45 },
  {  44,   135 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,   135 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,   135 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    45 },
  {  44,    4
37  Forum 2005-2010 (read only) / Interfacing / 120 khz output program wave question? on: March 20, 2009, 03:59:09 pm
Hi im using this program to generate a 120 khz frequency.. I asked a question before http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1236217277/5#5
but it got lost. So if you can upload this program and can see if it is a square wave and if its not recommend how i can make a square wave at 120 khz with arduino... thanks
uint8_t outPin = 2;

void setup()
{
  pinMode(outPin, OUTPUT);
  digitalWrite(outPin, LOW);
}

void loop()
{
  digitalWrite(outPin, HIGH);   // sets the pin on
  asm volatile("nop");
  asm volatile("nop");
  asm volatile("nop");
  asm volatile("nop");
  asm volatile("nop");
  asm volatile("nop");
  asm volatile("nop");
  digitalWrite(outPin, LOW);    // sets the pin off
  asm volatile("nop");
  asm volatile("nop");
  asm volatile("nop");
  asm volatile("nop");
  asm volatile("nop");
  asm volatile("nop");
  asm volatile("nop");
}
38  Forum 2005-2010 (read only) / Interfacing / Re: please help on: January 20, 2009, 08:49:18 pm
I tries my own version of the code based on this .... http://dukevisualstudies.org/lastmiles/?p=11

Now i tested it and the servo moves and its not supposed to move because the LDR sensors are not active. (i have not connected the sensors yet) So i do not know if theres a bug in my code, or there is some ambient data randomly passing through the serial port. So if i connect my sensors should this work fine or is it my code??


int Hservo = 7;
int Vservo = 6;
int Lsensor = 0;
int Msensor = 1;
int Rsensor = 2;


void setup()
{

  beginSerial(9600);
pinMode(Lsensor, INPUT);
pinMode(Msensor, INPUT);
pinMode(Rsensor, INPUT);
pinMode(Hservo, OUTPUT);
pinMode(Vservo, OUTPUT);
}
void loop()
{
int temp;


 if(Lsensor > Rsensor){
  for (temp = 0; temp <= 200; temp++)
digitalWrite(Vservo,HIGH);
delayMicroseconds(1800); // 1.8ms moves the servo clockwise
digitalWrite(Vservo,LOW);
delay(20); // 20ms

 }
 
 if(Lsensor < Rsensor){
  for (temp = 0; temp <= 200; temp++)
digitalWrite(Vservo,HIGH);
delayMicroseconds(1200); // 1.2ms moves the servo counterclockwise
digitalWrite(Vservo,LOW);
delay(20); // 20ms
}

 if(Lsensor < Msensor){
  for (temp = 0; temp <= 200; temp++)
digitalWrite(Vservo,LOW);
delay(20); // 20ms
}

 if(Rsensor < Msensor){
  for (temp = 0; temp <= 200; temp++)
digitalWrite(Vservo,LOW);
delay(20); // 20ms
}


 if(Lsensor > Rsensor){
  for (temp = 0; temp <= 200; temp++)
digitalWrite(Vservo,HIGH);
delayMicroseconds(1800); // 1.8ms moves the servo clockwise
digitalWrite(Vservo,LOW);
delay(20); // 20ms
}
}
39  Forum 2005-2010 (read only) / Interfacing / Re: please help on: January 19, 2009, 04:34:26 pm
anyone please i really need this to work. thanks
40  Forum 2005-2010 (read only) / Interfacing / Re: please help on: January 16, 2009, 05:54:44 pm
I finished the code, sadly all of the four servos i have are hacked, and i cant try it until i get some un-hacked servos. I compiled the program and it says it's fine. If you are a code genius please tell me that the code is all right. Thanks robotkid249

int servoPin = 7;  
int servoPin1 = 4;
int myAngle;                
int pulseWidth;
int pulseWidth1;
int myAngle1;
int val = 0;
int val2 = 1;
int val3 = 2;

void servoPulse(int servoPin, int myAngle) {
  pulseWidth = (myAngle * 11) + 500;  // converts angle to microseconds
  digitalWrite(servoPin, HIGH);       // set servo high
  delayMicroseconds(pulseWidth);      // wait a very small amount
  digitalWrite(servoPin, LOW);        // set servo low
  delay(20);                          // refresh cycle of typical servos (20 ms)
}
void servoPulse1(int servoPin1, int myAngle1) {
  pulseWidth1 = (myAngle1 * 11) + 500;  // converts angle to microseconds
  digitalWrite(servoPin1, HIGH);       // set servo high
  delayMicroseconds(pulseWidth1);      // wait a very small amount
  digitalWrite(servoPin1, LOW);        // set servo low
  delay(20);                          // refresh cycle of typical servos (20 ms)
}

void setup() {
  pinMode(servoPin, OUTPUT);          // set servoPin pin as output
   pinMode(servoPin1, OUTPUT);  
   pinMode(val, INPUT);
    pinMode(val2, INPUT);
     pinMode(val3, INPUT);
}

void loop() {
if(val > val2){
  for (myAngle=0; myAngle=10; myAngle++) {  
    (servoPin, myAngle);
  }
}
if(val < val2){
  for (myAngle=10; myAngle=0; myAngle++) {  
    (servoPin, myAngle);
  }
}
if(val3 > val2){
  for (myAngle=0; myAngle=0; myAngle++) {  
    (servoPin, myAngle);
  }
}
if(val3 > val){
  for (myAngle=0; myAngle=0; myAngle++) {  
    (servoPin, myAngle);
  }
}
  delay(300);
}
41  Forum 2005-2010 (read only) / Interfacing / Re: please help on: January 16, 2009, 05:00:36 pm
yes i think that sounds right. ill try to create the code when i get a chance.
42  Forum 2005-2010 (read only) / Interfacing / please help on: January 16, 2009, 02:44:50 pm
Hey i recently viewed this video on youtube.
I am not a smart person when it comes to code. Please if you can find this code that does exactly this or if you can try to make it yourself that would be great, because i really needed something like this...

::::smiley)))))))))))Robotkid249
43  Forum 2005-2010 (read only) / Interfacing / Re: Processing Head Tracking on: January 02, 2009, 10:00:21 pm
Yeah i know all of that i not that stupid:)smiley I meant like which libraries do i need for this to work.. And where can i find those files.
44  Forum 2005-2010 (read only) / Interfacing / Processing Head Tracking on: January 02, 2009, 08:43:05 pm
Hey guys! I found this,,, http://blogs.bl0rg.net/netzstaub/2008/08/24/wiimote-headtracking-in-processing/

Yet i have no clue how to use it or what to do with it. So please can someone tell me what to do. I am good with arduino stuff but not processing so please help me. Thanks.
45  Forum 2005-2010 (read only) / Interfacing / Re: Speak analog input with Adafruit wave shield on: December 27, 2008, 10:43:17 pm
Great idea, once i get my shield up and running i'll think about the house system :  )
Pages: 1 2 [3] 4 5 ... 17