Internet of Things
Internet of Things
CODE:
1 #include <Wire.h> //I2C Arduino Library
2 #include <LiquidCrystal.h> //LCD Library
3 #include <Stepper.h> // Include the header file
4 #define STEPS 32
5 #define addr 0x1E //I2C Address for The HMC5883
6 Stepper stepper(STEPS, 4, 6, 5, 7);// create an instance of the
stepper class using the steps
7 and pins
8 int val = 0;//setting the iniatial value for val
9 LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
10 //char junk;
11 //String inputString="";
12 void magnetometor()
13 {
14 int x,y,z; //triple axis data
15 //Tell the HMC what regist to begin writing data into
16 Wire.beginTransmission(addr);
17 Wire.write(0x03); //start with register 3.
18 Wire.endTransmission();
19
20 //Read the data.. 2 bytes for each axis.. 6 total bytes
21 Wire.requestFrom(addr, 6);
22 if(6<=Wire.available()){
23 x = Wire.read()<<8; //MSB x
24 x |= Wire.read(); //LSB x
25 43
26
27 y = Wire.read()<<8; //MSB y
28 y |= Wire.read(); //LSB y
29 }
30 float Pi = 3.14159; // Calculate the angle of the vector y,x
31 float heading = (atan2(y,x) * 180) / Pi; // Normalize to 0-360
32 if (heading < 0)
33 {
34 heading = 360 + heading;
35 }
36 lcd.clear();
37 lcd.setCursor(0,0);
38 lcd.print("Antenna position: ");
39 lcd.setCursor(0,2);
40 lcd.print(heading);
41 lcd.print(char(223));
42 delay(250);
43 lcd.clear();
44 if (Serial.available()>0)
45 {
46
47 lcd.print("Turning antenna");
48 val = Serial.parseInt();
49 stepper.step(val);
50 delay(1000);
51 lcd.clear();
52 }
53 else
54 {
55 lcd.setCursor(0,0);
56 lcd.print("Antenna position: ");
57 lcd.setCursor(0,2);
58 44
59 lcd.print(heading);
60 lcd.print(char(223));
61 }
62 }
63 void scroller()
64 {
65 lcd.setCursor(0,0);
66 lcd.print("SECTOR ANTENNA");
67 lcd.setCursor(0,2);
68 lcd.print("POSITIONER..");
69 // scroll 13 positions (string length) to the left
70 // to move it offscreen left:
71 for (int positionCounter = 0; positionCounter < 13; positionCounter+
+) {
72 // scroll one position left:
73 lcd.scrollDisplayLeft();
74 // wait a bit:
75 delay(250);
76 }
77 // scroll 29 positions (string length + display length) to the right
78 // to move it offscreen right:
79 for (int positionCounter = 0; positionCounter < 29; positionCounter+
+) {
80 // scroll one position right:
81 lcd.scrollDisplayRight();
82 // wait a bit:
83 delay(250);
84 }
85 // scroll 16 positions (display length + string length) to the left
86 // to move it back to center:
87 for (int positionCounter = 0; positionCounter < 16; positionCounter+
+) {
88 // scroll one position left:
89 lcd.scrollDisplayLeft();
90 45
91 // wait a bit:
92 delay(250);
93 }
94 // delay at the end of the
95
96 delay(5000);
97 lcd.clear();
98 }
99 void setup()
100 {
101
102 Serial.begin(9600);
103 lcd.begin(16,2);
104 scroller();
105 stepper.setSpeed(200);//set speed for the stepper motor
106 Wire.begin();//begin the I2C
107
108
109 Wire.beginTransmission(addr); //start talking
110 Wire.write(0x02); // Set the Register
111 Wire.write(0x00); // Tell the HMC5883 to Continuously Measure
112 Wire.endTransmission();
113 }
114 void loop()
115 {
116 for(;;)
117 {
118 magnetometor();//compass direction
119 }
120 }
2. Design a case study where digital twinning could help the industry
to automate things. Write a report on how United Technologies and
General Electric are utilizing this technology in their products
WHAT IS DIGITAL TWINNING?
A digital twin is a digital representation of a physical object or
system. The technology behind digital twins has expanded to include
large items such as buildings, factories and even cities, and some have
said people and processes can have digital twins, expanding the concept
even further. The idea first arose at NASA: full-scale mock-ups of
early space capsules, used on the ground to mirror and diagnose
problems in orbit, eventually gave way to fully digital simulations.
USE CASES:
These two digital-twin examples – the car and the cargo vessel – give
you a sense of potential use cases. Objects such as aircraft engines,
trains, offshore platforms, and turbines can be designed and tested
digitally before being physically produced. These digital twins could
also be used to help with maintenance operations. For example,
technicians could use a digital twin to test that a proposed fix for a
piece of equipment works before applying the fix the physical twin.
45