Please help me
Hi,
What IDE version are you running?
If you look in
SKETCH
Include Library
You should find its already there , just select it to put it in your sketch.
It comes with the IDE libraries.
Tom....
I used Arduino 1.6.5
my unit is Arduino Yun.
Im working now for The I²C Bus project.
but when i compile it then upload it ,there is no value output in the serial monitor
im working for this but there is nothing happen. There is nothing displayed in serial monitor i dont see any Wire library in my Sketch/Include Library
help please
Hi,
Does your sketch compile with wire.h included in it?
Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html
Tom....
Project: The I²C Bus "temperature monitor" there is no display output in the Serial monitor helpp me please
this is the code.
but there is no output display in the serial monitor
//Include Wire I2C library
#include <Wire.h>
int temp_address = 72; //1001000 written as decimal number
void setup()
{
//Start serial communication at 9600 baud
Serial.begin(9600);
//Create a Wire object
Wire.begin();
}
void loop()
{
//Send a request
//Start talking to the device at the specified address
Wire.beginTransmission(temp_address);
//Send a bit asking for register zero, the data register
Wire.write(0);
//Complete Transmission
Wire.endTransmission();
//Read the temperature from the device
//Request 1 Byte from the specified address
Wire.requestFrom(temp_address, 1);
//wait for response
while(Wire.available() == 0);
// Get the temp and read it into a variable
int c = Wire.read();
//Do some math to convert the Celsius to Fahrenheit
int f = round(c*9.0/5.0 +32.0);
//Send the temperature in degrees C and F to the serial monitor
Serial.print(c);
Serial.print("C ");
Serial.print(f);
Serial.println("F");
delay(500);
}
No idea what the problem is, too many possibilities.
Do it right, and it will work.
When i compile and upload it.. There is no display output in my serial monitor
#include <Wire.h>
//Include Wire I2C library
int temp_address = 72; //1001000 written as decimal number
void setup()
{
//Start serial communication at 9600 baud
Serial.begin(9600);
//Create a Wire object
Wire.begin();
}
void loop()
{
//Send a request
//Start talking to the device at the specified address
Wire.beginTransmission(temp_address);
//Send a bit asking for register zero, the data register
Wire.write(0);
//Complete Transmission
Wire.endTransmission();
//Read the temperature from the device
//Request 1 Byte from the specified address
Wire.requestFrom(temp_address, 1);
//wait for response
while(Wire.available() == 0);
// Get the temp and read it into a variable
int c = Wire.read();
//Do some math to convert the Celsius to Fahrenheit
int f = round(c*9.0/5.0 +32.0);
//Send the temperature in degrees C and F to the serial monitor
Serial.print(c);
Serial.print("C ");
Serial.print(f);
Serial.println("F");
delay(500);
}
Most probably your code hangs here:
//wait for response
while(Wire.available() == 0);
Hi,
You have got the serial monitor set for 9600baud in the IDE?
Please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html
Tom.....
Hi,
I just loaded an example from your reference.
It has sooo much more setup and preparation statements than you copy.
You have no statement allocating comms pins for a start.
/*
Exploring Arduino - Code Listing 8-2: I2C Temperature Sensors Code with Shift Register LEDs and Serial Communication
http://www.exploringarduino.com/content/ch8
Copyright 2013 Jeremy Blum ( http://www.jeremyblum.com )
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License v3 as published by
the Free Software Foundation.
*/
//Reads temp from I2C temperature sensor
//show it on the LED bar graph, and show it in Processing
//Include Wire I2C library
#include <Wire.h>
const int SER =8; //Serial Output to Shift Register
const int LATCH =9; //Shift Register Latch Pin
const int CLK =10; //Shift Register Clock Pin
int temp_address = 72;
//Possible LED settings
int vals[8] = {1,3,7,15,31,63,127,255};
void setup()
{
//Instantiate serial communicatuion at 9600 bps
Serial.begin(9600);
//Create a Wire Object
Wire.begin();
//Set shift register pins as outputs
pinMode(SER, OUTPUT);
pinMode(LATCH, OUTPUT);
pinMode(CLK, OUTPUT);
}
void loop()
{
//Send a request
//Start talking to the device at the specified address
Wire.beginTransmission(temp_address);
//Send a bit asking for register zero, the data register
Wire.write(0);
//Complete Transmission
Wire.endTransmission();
//Read the temperature from the device
//Request 1 Byte from the specified address
Wire.requestFrom(temp_address, 1);
//wait for response
while(Wire.available() == 0);
// Get the temp and read it into a variable
int c = Wire.read();
//Map the temperatures to LED settings
int graph = map(c, 24, 31, 0, 7);
graph = constrain(graph,0,7);
digitalWrite(LATCH, LOW); //Latch low - start sending data
shiftOut(SER, CLK, MSBFIRST, vals[graph]); //Send data, most significant bit first
digitalWrite(LATCH, HIGH); //Latch high - stop sending data
//Do some math to convert the Celsius to Fahrenheit
int f = round(c*9.0/5.0 +32.0);
Serial.print(c);
Serial.print("C,");
Serial.print(f);
Serial.print("F.");
delay(500);
}
Why have you deleted so much of a perfectly good program.
Does this work with your hardware.
Have you got all your hardware connected.
Read the chapter explanation of I2C.
Tom........