Show Posts
Pages: [1]
1  Using Arduino / Project Guidance / Re: Attiny85 Communication with Arduino UNO on: November 28, 2012, 08:49:40 am
Following the instructions you provided in reply #20 worked perfectly. I'm finally printing out the string. I misunderstood your instructions in replay #18. Thank you so much. This is one headache gone.
2  Using Arduino / Project Guidance / Re: Attiny85 Communication with Arduino UNO on: November 28, 2012, 01:02:07 am
When I do that I get no output on the serial monitor. If I remove the jumper I see the same character garbage. The sketch I'm using now is very simple and should just print out hello world.

Code:

void setup()  {
  Serial.begin(9600);
}

void loop()
{
 Serial.println("Hello World");
  delay(10);
}
3  Using Arduino / Project Guidance / Re: Attiny85 Communication with Arduino UNO on: November 27, 2012, 06:10:30 pm
Erni, so I used your sketch and the links to the cores you sent me. However, out of the pin, to the arduino, I'm only getting the same garbage from the serial monitor.

I read that you can change the frequency of the chip by choosing your board and frequency and choosing burn bootloader in the tools menu. I put a link to a picture of this here: http://imgur.com/f6hqD

The code on the UNO itself shouldn't matter though correct? It should still receive data on the RX pin and print to the serial regardless right? Or do I need to have code on the UNO that reads in the data and then outputs it to the serial monitor?

EDIT:
So I found the quote below explaining what the y character means. I confirmed this by loading the code below onto the Arduino UNO and printing:
Code:
I received: -1
to the serial monitor. However, I do not understand why there is no data to read. I'm printing the string "Hello World", so it seems that it should see some sort of data.

Quote
The y with the two dots over it is caused by printing a -1 as an ASCII character. The -1 comes from trying to read data from the serial port, when there is no data to read.

Code:
//Arduino UNO Read Data COM Test
int incomingByte = 0;   // for incoming serial dat

void setup()  {
  Serial.begin(9600);
}

void loop()
{
  
    incomingByte = Serial.read();

    // say what you got:
    Serial.print("I received: ");
    Serial.println(incomingByte, DEC);
 
}
4  Using Arduino / Project Guidance / Re: Attiny85 Communication with Arduino UNO on: November 27, 2012, 05:46:57 pm
If I use TinyDebugSerial do I include it like softwareSerial.h. SoftwareSerial is included with the Arduino Software I know. Is there anything specific that I need to to in order to utilize TinyDebugSerial? Thanks for all your help.
5  Using Arduino / Project Guidance / Re: Attiny85 Communication with Arduino UNO on: November 27, 2012, 05:31:41 pm
Coding Badly,

The color sensing will come in spurts, so in secession it will receive the "go" signal and need to sense up to 6 colors, maybe within 3 seconds of each other, so 18 seconds total. An individual color determination takes approximately 2 seconds.
6  Using Arduino / Project Guidance / Re: Attiny85 Communication with Arduino UNO on: November 27, 2012, 05:18:47 pm
I got it compile. You were probably right that I installed the core incorrectly. Now it loads onto the Attiny85. However, I checked my order history from newark, and realized that my Attiny85 is 20MHz. The files here though: https://github.com/damellis/attiny/zipball/Arduino1 which are provided via this tutorial: http://hlt.media.mit.edu/?p=1695 , include the 20MHz Attiny85, but with an external clock, which I am not using.

Here is the chip I have: http://www.newark.com/jsp/search/productdetail.jsp?SKU=68T3808

Also, choosing the 8MHz will let me flash code, but my serial monitor output is the same string of ÿ.
7  Using Arduino / Project Guidance / Re: Attiny85 Communication with Arduino UNO on: November 27, 2012, 04:59:51 pm
Erni,

When I use those cores, my code won't compile, it throws a lot of errors, the first being that INPUT was not declared in the scope. I'm using the exact same sketch.
8  Using Arduino / Project Guidance / Re: Attiny85 Communication with Arduino UNO on: November 27, 2012, 12:21:25 pm
Below is the code that I have flashed to the Attiny85. I called PB4, which is pin 3 of the Attiny, to be the txPin. Per Coding Badly's suggestion, I realized that I don't actually need an rxPin, however, the code will not compile if I don't declare one, so I just called it pin 9, which is not on the chip. I then connected my txPin on the Attiny85 to the rxPin on the Arduino UNO (pin 0). There code on the Arduino UNO is just the code from hi low tech that allows you to use the UNO as an ISP.

I have specified my baud rate for SoftwareSerial on the Attiny85 as 9600. If I match the serial monitor's baud rate to that of the Attiny85, I get a constant string of ÿ's output on the serial monitor. I included a link to my screen shot of this below. If I vary the baud rate of the serial monitor such that it does not match that of the program on the Attiny85, I get different strings of equally meaningless characters (I have included link to me screen shot of this as well). If I change the baud rate on the Attiny85 to something lower, I get the same string, just it updates less often. I have tried changing the baud rate on both the Attiny85 and the serial monitor, but I get the same results.

Code:
#include <SoftwareSerial.h>

const int txPin = 4;
const int rxPin = 9;

// set up a new serial port
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);

void setup()  {
  

  // set the data rate for the SoftwareSerial port

  //define pin modes for tx:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  
  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);

}

void loop()
{
  mySerial.println("Hello World");
  delay(10);
}

Matching Baud Rates: http://imgur.com/fI3Ms

Not Matching Baud Rates: http://imgur.com/GI585
9  Using Arduino / Project Guidance / Re: Attiny85 Communication with Arduino UNO on: November 27, 2012, 10:26:20 am

The signal being "go" or is there information that has to be sent?


It would be easier to just send it a "go" signal, which would entail only sending a high signal to one of the pins on the Attiny85. Therefore I wouldn't need the Rx pin.

Also, I've tried changing the Tx pin to a few different pins, but when using the Arduino UNO as an ISP as is shown by hi low tech, pin 0 is actually the lower left pin. Therefore if I wanted pin 6 to be Tx I would write what is shown below correct?

Code:
const int txPin = 1;

I did that, but on my serial monitor, I don't get anything at all. At one point I was receiving a string of ÿ, but I'm not exactly sure how I achieved that.

Code:
// ATMEL ATTINY45 / ARDUINO
//
//                        +-\/-+
// Ain0 (D 5) PB5  1|    |8  Vcc
// Ain3 (D 3) PB3  2|    |7  PB2 (D 2)  Ain1
// Ain2 (D 4) PB4  3|    |6  PB1 (D 1) pwm1
//               GND  4|    |5  PB0 (D 0) pwm0
//       
10  Using Arduino / Microcontrollers / Re: ATtiny and software serial sending garbage on: November 26, 2012, 09:48:47 pm
Could you post your code please?
11  Using Arduino / Project Guidance / Attiny85 Communication with Arduino UNO on: November 26, 2012, 09:22:42 pm
I have been successful in flashing an Attiny85 using the tutorial found here: http://hlt.media.mit.edu/?p=1695. I am using the Attiny85 to determine the color of an object given six options (as in, the color will only be one of 6 possibilities). Once having made its decision, it should transmit that information to another microcontroller, in my case the Atmega328 (the microcontroller used on the Arduino UNO). The Attiny85 should also be able to receive the signal to begin the color sensing process. Therefore I know I need an Rx and Tx pin. Three of the pins are being used as digital outputs to set a Red, Green, and Blue LED high at different times, and another pin to act as an ADC to read in an analog voltage realized at an LDR. Using the reset as an ADC, I should have enough pins.

However, I am having trouble getting the Attiny85 to communicate at all. I tried using softwareSerial, as is shown in the code below, and connecting pin 0 (Rx) on the Arduino to the pin I specified as Tx on the Attiny85, and pin 1 (Tx) to the pin I specified as Rx on the Attiny85. I then opened the serial monitor on my computer, but I don't get anything at all. Is it possible to accomplish what I am trying to do?

I know that you can program the ATtiny85 using bascom and maybe implement USI, but to do that you can't use the Arduino environment to program in C or use the Arduino as an ISP (I think). Any help would be much appreciated. Thanks.

Code:
#include <SoftwareSerial.h>

const int rxPin = 6;
const int txPin = 7;

// set up a new serial port
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);

void setup()  {
 
   define pin modes for tx, rx:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
 
  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);

}

boolean running = true;

void loop()
{
  mySerial.println("Hello World");
  delay(10);

}
Pages: [1]