Basics of Microcontrollers

CC3200 Micrcontroller LED Blinking code.

 void setup()

{

pinMode(11,INPUT_PULLUP);

pinMode(29,OUTPUT);

}

void loop()

{

int x=digitalRead(11);

if(x==1)

{

digitalWrite(29,HIGH);

}

else

{

digitalWrite(29,LOW);

}

}



1) UART TEMPERATURE AND LED PIN DIAGRAM WITH CODE





Arduino 1 code:

//First MC Code

#define TEMP_SENSOR A0  // TMP36 connected to A0

void setup() {

 Serial.begin(9600);  // Start Serial communication

}

void loop() {

 int sensorValue = analogRead(TEMP_SENSOR);  // Read sensor value

    float voltage = sensorValue * (5.0 / 1024.0);  // Convert to voltage

    float temperature = (voltage - 0.5) * 100.0;  // Convert to Celsius

    byte *tempBytes = (byte *)&temperature;  // Get the float bytes

    Serial.write(tempBytes, sizeof(float));  // Send all 4 bytes of float

    delay(1000);  // Send every second

}


Arduino 2 code: 

#define LED_PIN 2  // LED connected to pin 2

void setup() {

    pinMode(LED_PIN, OUTPUT);

    Serial.begin(9600);  // Start Serial communication

}

void loop() {

    if (Serial.available() >= sizeof(float)) {  // Ensure 4 bytes are available

        float receivedTemp;

        Serial.readBytes((char *)&receivedTemp, sizeof(float));  // Read 4 bytes

        // LED Control based on temperature

        if (receivedTemp > 25.0) {

            digitalWrite(LED_PIN, HIGH);  // Turn LED ON

        } else {

            digitalWrite(LED_PIN, LOW);   // Turn LED OFF

        }

        Serial.print("Temperature Received: ");

        Serial.println(receivedTemp);  // Print the received float

    }

}


2) I2C Module With connections


Arduino 1 code:

//Master Code
#include <Wire.h> //i2c library
int pushbutton=A0;
void setup()
{
  Wire.begin();
  pinMode(pushbutton,INPUT);
}
int x = 0;
void loop()
{
  Wire.beginTransmission(8); 
  x=digitalRead(pushbutton);
   Wire.write(x);                
  Wire.endTransmission();   
  delay(500);
}

Arduino 2 code:

//Slave Code
#include <Wire.h>
int led=13;
void setup()
{
  Wire.begin(8);                
  Wire.onReceive(receiveEvent); 
  Serial.begin(9600);
  pinMode(led,OUTPUT);
}
void loop()
{
  delay(100);
}
void receiveEvent(int howMany)
{
  int x = Wire.read();    
  Serial.println(x); 
 if (x==1)
 {
   digitalWrite(led,HIGH);
 }
 else
 {
   digitalWrite(led,LOW);
 } 
}

Comments

  1. descargar xupertv significa obtener e instalar esta aplicaci贸n de streaming en un dispositivo como celular, tablet o Smart TV para disfrutar de canales en vivo, pel铆culas y series gratis. Normalmente se descarga en formato APK desde p谩ginas web, ya que no est谩 disponible en tiendas oficiales. El proceso es r谩pido y f谩cil, pero es importante hacerlo desde fuentes confiables para evitar riesgos de seguridad o problemas con el dispositivo.

    ReplyDelete
  2. chipotle calorie refers to the number of calories in meals from Chipotle Mexican Grill, which can vary widely depending on the ingredients and portion sizes you choose. For example, a burrito with rice, beans, meat, cheese, and guacamole can range from 700 to over 1,200 calories, while a salad with similar toppings might be lower, around 500–900 calories.

    ReplyDelete

Post a Comment

Popular posts from this blog

Meander Line Calculator

MIMO Antenna Parameters

DIPOLE ANTENNA CALCULATOR