-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathhelloWorld_UNO.ino
135 lines (120 loc) · 3.36 KB
/
helloWorld_UNO.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// ===============================================
// SIMUINO_BEGIN
// ===============================================
// BOARD_TYPE: UNO
// SKETCH_NAME: HelloWorld_UNO.ino
// SIM_LENGTH: 600
// WIN_LAYOUT: 2
// SO_DELAY: 40
//================================================
// Scenario
//================================================
//
// SCENDIGPIN 10 1 0
// SCENDIGPIN 10 50 1
// SCENDIGPIN 10 100 0
// SCENDIGPIN 10 200 1
// SCENDIGPIN 9 1 0
// SCENDIGPIN 9 40 1
// SCENDIGPIN 9 130 0
//
// SCENANAPIN 4 1 5
// SCENANAPIN 5 1 8
// SCENANAPIN 4 80 12
// SCENANAPIN 5 120 18
//
//================================================
// Simuino log text customization
//================================================
// PINMODE_OUT: 11 "PIN: Led Urgent"
// PINMODE_OUT: 12 "PIN: Led Blink"
// DIGITALWRITE_LOW: 11 "Waiting"
// DIGITALWRITE_HIGH: 11 "Urgent"
// DIGITALWRITE_LOW: 12 "Led is off"
// DIGITALWRITE_HIGH: 12 "Led is on"
// DIGITALREAD: 9 "Read from nine"
// DIGITALREAD: 10 "Read from ten"
// ANALOGREAD: 4 "read analog four"
// ANALOGREAD: 5 "read analog five"
//-------- DIGITAL PIN settings ------------------
#include <EEPROM.h>
// Leds
int URGENTLED = 11;
int BLINKLED = 12;
int IN_PIN = 10;
int CONTROL = 9;
//-------- ANALOGUE PIN settings
int SENSOR1 = 4;
int SENSOR2 = 5;
//================================================
// Function Declarations
//================================================
void blinkLed(int n);
//================================================
void urgent()
//================================================
{
digitalWrite(URGENTLED, HIGH);
delay(401);
digitalWrite(URGENTLED, LOW);
}
//================================================
void very_urgent()
//================================================
{
digitalWrite(URGENTLED, HIGH);
delay(402);
digitalWrite(URGENTLED, LOW);
}
//================================================
void setup()
//================================================
{
Serial.begin(9600);
attachInterrupt(0,urgent, CHANGE);
attachInterrupt(1,very_urgent, RISING);
pinMode(BLINKLED,OUTPUT);
pinMode(URGENTLED,OUTPUT);
pinMode(IN_PIN,INPUT);
pinMode(CONTROL,INPUT);
}
//================================================
void loop()
//================================================
{
int value1,value2,i;
Serial.println("Hello Simuino!");
value1 = analogRead(SENSOR1);
value2 = analogRead(SENSOR2);
Serial.print("Analog 1 value read: ");
Serial.println(value1);
Serial.print("Analog 2 value read: ");
Serial.println(value2);
blinkLed(value1);
value1 = digitalRead(IN_PIN);
value2 = digitalRead(CONTROL);
Serial.print("Digital IN_PIN read: ");
Serial.println(value1);
Serial.print("Digital CONTROL read: ");
Serial.println(value2);
delay(1000);
EEPROM.write(678,311);
int lue = EEPROM.read(678);
Serial.print("EEPROM value is: ");
Serial.println(lue);
}
//================================================
void blinkLed(int n)
//================================================
{
int i;
for(i=1;i<=10;i++)
{
digitalWrite(BLINKLED, HIGH);
delay(500);
digitalWrite(BLINKLED, LOW);
}
}
//================================================
// End of Sketch
//================================================