Advertisement
pleasedontcode

Programma Ivan

May 1st, 2023 (edited)
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Arduino 2.04 KB | Source Code | 0 0
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     Pleasedontcode gives you this package free of charge and you
  7.     can use it for your personal projects. We will not be held liable for
  8.     any loss or damage of any kind. For all terms and conditions,
  9.     please visit pleasedontcode.com/termsandconditions
  10.  
  11.     - Project: Test Ivan
  12.     - Source Code created on: 2023-05-01 16:42:18
  13.     - Source Code generated by: Alessandro
  14.  
  15. ********* Pleasedontcode.com **********/
  16.  
  17. /****** DEFINITION OF LIBRARIES *****/
  18. #include "Arduino.h"
  19.  
  20. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  21. #define LED1_PIN_D2 2
  22. #define LED2_PIN_D3 3
  23.  
  24. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  25. /***** used to store raw data *****/
  26. bool LED1_PIN_D2_rawData = 0;
  27. bool LED2_PIN_D3_rawData = 0;
  28.  
  29. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  30. /***** used to store data after characteristic curve transformation *****/
  31. float LED1_PIN_D2_phyData = 0.0;
  32. float LED2_PIN_D3_phyData = 0.0;
  33.  
  34. void setup() {
  35.   // put your setup code here, to run once:
  36.   pinMode(LED1_PIN_D2, OUTPUT);
  37.   pinMode(LED2_PIN_D3, OUTPUT);
  38. }
  39.  
  40. void loop() {
  41.   // put your main code here, to run repeatedly:
  42.   int value1 = analogRead(A0); // read analog value from A0 pin
  43.   int value2 = analogRead(A1); // read analog value from A1 pin
  44.   Confronto(value1, value2); // call the Confronto function to compare the values
  45.   updateOutputs(); // Refresh output data
  46. }
  47.  
  48. void updateOutputs() {
  49.   digitalWrite(LED1_PIN_D2, LED1_PIN_D2_rawData);
  50.   digitalWrite(LED2_PIN_D3, LED2_PIN_D3_rawData);
  51. }
  52.  
  53. void Confronto(int Intero1, int intero2) {
  54.   /***** REQUIREMENT 1 *****/
  55.   /* Riceve in input due valori interi, che poi li */
  56.   /* confronta e accende il pin LED1 se i due valori */
  57.   /* sono uguali oppure accende LED2 se i valori sono */
  58.   /* diversi */
  59.   if (Intero1 == intero2) {
  60.     LED1_PIN_D2_rawData = 1;
  61.     LED2_PIN_D3_rawData = 0;
  62.   } else {
  63.     LED1_PIN_D2_rawData = 0;
  64.     LED2_PIN_D3_rawData = 1;
  65.   }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement