0

i have code in the Arduino ide for a temperature sensor that shows the temperature on three 7 segment displays, it shows the temperature to one decimal point. using an arduino uno. I am struggling to convert the below code to assembly. can someone please help?

#include <SevSeg.h>
#include "SevSeg.h" // Included the library for the 7 segment display
SevSeg sevseg;  // Created an object
const int sensor_pin = A0; // initialized A0 for LM35 sensor
float tempc;  //variable to store temperature in degree Celsius
float sensor_out;  // variable to store the output
unsigned long interval = 1000; // the time we need to wait
unsigned long previousMillis = 0; // millis() returns an unsigned long.
void setup() {
 pinMode(sensor_pin, INPUT);  // Declared the sensor pin as Input
 byte numDigits = 3;      it to 3.
 byte digitPins[] = {10, 11, 12};   
 segment displays
 byte segmentPins[] = {9, 2, 3, 5, 6, 8, 7, 4};   
 pins of displays
 bool resistorsOnSegments = true;
 bool updateWithDelaysIn = true;
 byte hardwareConfig = COMMON_CATHODE;   // Type of display we are using
 sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
 sevseg.setBrightness(100);  
 }
 void loop() {
  sensor_out = analogRead(sensor_pin); 
  tempc = (sensor_out * 500) / 1024; 
  tempc = tempc - 32;
 tempc = tempc * 5;
 tempc = tempc / 9;
 delay_function(); 
 sevseg.refreshDisplay(); 
}
void delay_function() {
unsigned long currentMillis = millis();
if ((unsigned long)(currentMillis - previousMillis) >= interval) {
sevseg.setNumber(tempc, 1);   // Sets temperature on display
previousMillis = millis();
}
}
6
  • 2
    It would be easier to just let the compiler do it for you. Commented May 4, 2020 at 20:14
  • Why would you want to? What are you going to do with the assembly code? Commented May 4, 2020 at 21:20
  • forum.arduino.cc/index.php?topic=50169.0 Commented May 5, 2020 at 7:01
  • According to a comment in the code, you are using an LM35, which is calibrated in Celsius (10 mV/°C). Yet the code does what looks like a Fahrenheit to Celsius conversion, which would make sense with an LM34, but not with an LM35. Commented May 5, 2020 at 10:19
  • with the assembly code i am going to use it in atmel studio to upload it onto an arduino and run the program. i also want to see what it looks like and i am also learning assembly code. Commented May 11, 2020 at 19:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.