0

I brought an ATmega328p chip today, which I bootloaded later on and I tried some basic circuit examples (like blink LED) with the chip (Minimizing the circuitry) and it worked perfectly fine. When I was programming the Arduino board and I interfaced the LCD it was working perfectly fine.

Here is the code:

#include<LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 
const int sensor=A1; // Assigning analog pin A1 to variable 'sensor'
float tempc;  //variable to store temperature in degree Celsius
float tempf;  //variable to store temperature in Fahreinheit 
float vout;  //temporary variable to hold sensor reading

void setup() {
  pinMode(sensor,INPUT); // Configuring pin A1 as input
  Serial.begin(9600);
  lcd.begin(16,2);
  delay(500);
}

void loop() {
  vout=analogRead(sensor);
  vout=(vout*500)/1023;
  tempc=vout; // Storing value in Degrees Celsius
  tempf=(vout*1.8)+32; // Converting to Fahrenheit
  lcd.setCursor(0,0);
  lcd.print("in DegreeC= ");
  lcd.print(tempc);
  lcd.setCursor(0,1);
  lcd.print("in Fahrenheit=");
  lcd.print(tempf);
  delay(1000); //Delay of 1 second for ease of viewing in serial monitor
}

This is for my temperature sensor project. But the problem is, when I uploaded the sketch into the chip, it is not working.

I want to make a temperature monitoring system without the Arduino board and want to use the microcontroller instead.

  • 1
    How is it not working? – Majenko Apr 10 '18 at 20:43
  • it is showing black blocks only – Peouse Dutta Apr 10 '18 at 20:45
  • 1
    Please show your schematic. – Majenko Apr 10 '18 at 20:45
  • 1
    I'd guess a hardware problem if the sketch works on an arduino board. You need to include the schematic of your hardware. – Craig Apr 10 '18 at 20:46
  • All rows as black blocks is usually that the contrast is set too high. You need to have a variable resistor between GND and VCC, with the tap of the pot connected to the contrast pin. One row of black blocks in a 2-line display, or 2 rows in a 4-line display usually indicate an uninitialized display, which would point toward a wiring problem. – jose can u c Apr 11 '18 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.