diff --git a/activity_2/img/explosion.png b/activity_2/img/explosion.png
new file mode 100644
index 0000000000000000000000000000000000000000..d547e51edd73558656c24907c3b9e516ab83b121
Binary files /dev/null and b/activity_2/img/explosion.png differ
diff --git a/activity_2/img/r1.png b/activity_2/img/r1.png
index a31d8034b049722f3462df0dd0f0d4e19321f312..d6f643aaea9ef5fd99dbd2fd5a212a0826a7438d 100644
Binary files a/activity_2/img/r1.png and b/activity_2/img/r1.png differ
diff --git a/activity_2/img/r2.png b/activity_2/img/r2.png
index 07b615eb53bf4c1ed2ee5e9397876e4f4a71d116..96f53395f0f5055054b61504e6655c8414e858ea 100644
Binary files a/activity_2/img/r2.png and b/activity_2/img/r2.png differ
diff --git a/activity_2/img/r3.png b/activity_2/img/r3.png
index 4d7280ce37f31e6af9a48ca77a03690c7cbdc1ae..04a923e2474a4ca31ed5e045fae9f226facd517d 100644
Binary files a/activity_2/img/r3.png and b/activity_2/img/r3.png differ
diff --git a/activity_2/img/r4.png b/activity_2/img/r4.png
index a14bff70e2d8fedf6b7d0314aab6950be2517991..9b30cc4ffe72c6e8c400e928d294b18db6ed3966 100644
Binary files a/activity_2/img/r4.png and b/activity_2/img/r4.png differ
diff --git a/activity_2/index.html b/activity_2/index.html
index db09f48edbab3d360d3057bfa3330411fa844a35..486b94786bbcf7bd45a775dfe6b280c44e18ad3e 100644
--- a/activity_2/index.html
+++ b/activity_2/index.html
@@ -25,6 +25,16 @@
 
 
 	<body>
+		<div id="intro_modal" class="modal">
+		  <div class="modal-content">
+		    <span class="close">&times;</span>
+				<h1 style="text-align: center;">Bienvenue dans la mission 2 !</h1>
+				<p>Le carburant est chargé dans la fusée, les astronautes sont à bord et tous les voyants sont au vert... C'est l'heure du décollage !</p>
+				<p>Il faut mettre la fusée sur orbite. Pour cela, on contrôle la puissance des moteurs de la fusée. Plus ils fonctionnent de façon puissante, plus ils consomment de carburants. Heureusement, une fusée est constituée de plusieurs étages, dès qu'un étage est vide, on peut le larguer et continuer avec le carburant de celui d'après. </p>
+				<p>Attention également, dans la zone dite de "Max Q" (pression dynamique maximale), si la fusée va trop vite, elle risque d'exploser. Pensez à réduire la puissance des moteurs dans cette zone donc !</p>
+				<p style="text-align: center;"><strong>A vous de jouer ! Bon vol !</strong></p>
+		  </div>
+		</div>
 		<header id="header"></header>
 
 		<section class="mainSection">
diff --git a/activity_2/main-script.js b/activity_2/main-script.js
index b2aa8b30d674245f29a035c20a560c497b41b990..911c24de36b71134cbfe1625a5ecc21e7b30ee43 100644
--- a/activity_2/main-script.js
+++ b/activity_2/main-script.js
@@ -2,13 +2,61 @@
 avec les fonctions et variables déjà définies dans 'activity_functions.js' du
 dossier 'res'.*/
 
+// Gets the modal (intiated as the intro_modal at first)
+var modal = document.getElementById("intro_modal");
+// Get the <span> element that closes the modal
+var span = document.getElementsByClassName("close")[0];
 
-function init_var() {
+// Displays the modal when DOM is Loaded
+document.addEventListener('DOMContentLoaded', event => {
+  modal.style.display = "block";
+});
+// When the user clicks on <span> (x), close the modal
+span.onclick = function() {
+  modal.style.display = "none";
+}
+// When the user clicks anywhere outside of the modal, close it
+window.onclick = function(event) {
+  if (event.target == modal) {
+    modal.style.display = "none";
+  }
 }
 
-/*var draw = SVG().addTo('#animationArea').size(640, 480)
-var rect = draw.rect(600, 400).attr({ fill: '#f06' })
-*/
+
+
+
+
+var firstTime;
+var curSpeed;
+var curPos;
+var curStage;
+var fuel_ratio;
+var power_ratio;
+var rocketLaunched;
+var simu_timeouts = [];
+var manual_enabled;
+
+var sky_rect
+var maxq_rect
+var maxq_text
+var path
+var rocket
+var length
+
+var fuel_rect
+var fuel_box
+var fuel_text
+
+var power_rect
+var power_box
+var power_text
+
+var rocket_img
+
+
+
+
+
 var canvas = SVG().addTo('#animationArea').size(660, 510)
 
 var fuel_gradient = canvas.gradient('linear', function(add) {
@@ -23,34 +71,174 @@ var sky_gradient = canvas.gradient('linear', function(add) {
   add.stop(0, '#4cdaff')
   add.stop(1, '#001b91')
 }).from(0, 1).to(0, 0)
+sky_rect = canvas.rect(500, 350).fill(sky_gradient).stroke({ width: 3, color: '#333' }).attr({x: 5, y: 5})
+maxq_rect = canvas.rect(500, 30).stroke({ width: 3, color: '#555' }).attr({x: 5, y: 220, fill:'#FFA343', })
+maxq_text = canvas.text("Zone de max Q").attr({x: 350, y:220})
+path = canvas.path("M40,353 C40,70 300,48 503,41").fill('none').stroke({width:5, color: '#ff0000'})
+rocket = canvas.image('img/r1.png').size(30, 1000).center(40,353)
+length = path.length()
+
+fuel_rect = canvas.rect(490, 50).attr({x: 160, y: 450, fill: fuel_gradient})
+fuel_box = canvas.rect(490, 50).fill('none').stroke({ width: 3, color: '#333' }).attr({x: 160, y: 450})
+fuel_text = canvas.text("Carburant de l'étage :").attr({x: 0, y: 460})
 
-var sky_rect = canvas.rect(400, 350).fill(sky_gradient).stroke({ width: 3, color: '#333' }).attr({x: 5, y: 5})
-var path = canvas.path("M40,353 C40,70 300,48 403,41").fill('none').stroke({width:5, color: '#ff0000'})
-var rocket = canvas.image('img/lander.png').size(75, 75)
-var length = path.length()
+power_rect = canvas.rect(490, 50).attr({x: 160, y: 395, fill: power_gradient})
+power_box = canvas.rect(490, 50).fill('none').stroke({ width: 3, color: '#333' }).attr({x: 160, y: 395})
+power_text = canvas.text("Puissance moteurs :").attr({x: 0, y: 405})
 
-var fuel_rect = canvas.rect(490, 50).attr({x: 160, y: 450, fill: fuel_gradient})
-var fuel_box = canvas.rect(490, 50).fill('none').stroke({ width: 3, color: '#333' }).attr({x: 160, y: 450})
-var fuel_text = canvas.text("Carburant de l'étage :").attr({x: 0, y: 460})
+rocket_img = canvas.image('img/r1.png').attr({x: 550, y : 0})
 
-var power_rect = canvas.rect(490, 50).attr({x: 160, y: 395, fill: power_gradient})
-var power_box = canvas.rect(490, 50).fill('none').stroke({ width: 3, color: '#333' }).attr({x: 160, y: 395})
-var power_text = canvas.text("Puissance moteurs :").attr({x: 0, y: 405})
+function enableManual() {
+  manual_enabled = true;
+  document.addEventListener('keydown', function(event) {
+      if(event.keyCode == 38) {
+          changePower(power_ratio+0.01)
+      }
+      else if(event.keyCode == 40) {
+          changePower(power_ratio-0.01)
+      } else if (event.keyCode == 32) {
+        if (rocketLaunched) changeRocketStage()
+        else launchRocket()
+      }
+  });
+}
+
+
+
+function init_var() {
+  for (var i=0; i<simu_timeouts.length; i++) {
+  clearTimeout(simu_timeouts[i]);
+  }
+  console.log("Initialisation de la simulation")
+  firstTime = (new Date()).getTime()
+  manual_enabled = false;
+  curPos = 0;
+  curSpeed = 0;
+  curStage = 1;
+  rocketLaunched = false;
+  canvas.clear()
+  var fuel_gradient = canvas.gradient('linear', function(add) {
+    add.stop(0, '#ff2e27')
+    add.stop(1, '#ffde00')
+  })
+  var power_gradient = canvas.gradient('linear', function(add) {
+    add.stop(0, '#3c8001')
+    add.stop(1, '#93f45e')
+  })
+  var sky_gradient = canvas.gradient('linear', function(add) {
+    add.stop(0, '#4cdaff')
+    add.stop(1, '#001b91')
+  }).from(0, 1).to(0, 0)
+  sky_rect = canvas.rect(500, 350).fill(sky_gradient).stroke({ width: 3, color: '#333' }).attr({x: 5, y: 5})
+  maxq_rect = canvas.rect(500, 30).stroke({ width: 3, color: '#555' }).attr({x: 5, y: 220, fill:'#FFA343', })
+  maxq_text = canvas.text("Zone de max Q").attr({x: 350, y:220})
+  path = canvas.path("M40,353 C40,70 300,48 503,41").fill('none').stroke({width:5, color: '#ff0000'})
+  rocket = canvas.image('img/r1.png').size(30, 1000).center(40,353)
+  length = path.length()
+
+  fuel_rect = canvas.rect(490, 50).attr({x: 160, y: 450, fill: fuel_gradient})
+  fuel_box = canvas.rect(490, 50).fill('none').stroke({ width: 3, color: '#333' }).attr({x: 160, y: 450})
+  fuel_text = canvas.text("Carburant de l'étage :").attr({x: 0, y: 460})
+
+  power_rect = canvas.rect(490, 50).attr({x: 160, y: 395, fill: power_gradient})
+  power_box = canvas.rect(490, 50).fill('none').stroke({ width: 3, color: '#333' }).attr({x: 160, y: 395})
+  power_text = canvas.text("Puissance moteurs :").attr({x: 0, y: 405})
+
+  rocket_img = canvas.image('img/r1.png').attr({x: 550, y : 0})
+  changeFuel(1, 0)
+  changePower(0, 0)
+  stepSimulation(getCurTime())
+}
+
+function launchRocket() {
+  rocketLaunched = true;
+}
+
+function getCurTime() {
+  return(new Date()).getTime() - firstTime;
+}
+
+function update_speed(deltaT) {
+  if (curPos <= 0 && curSpeed < 0 && power_ratio<=0.5) curSpeed = 0
+  else if (!rocketLaunched) curSpeed = 0
+  else curSpeed = curSpeed + (power_ratio-0.5)*deltaT*0.01
+
+}
+
+function update_pos(deltaT) {
+  curPos = Math.max(curPos + curSpeed*deltaT, 0);
+
+}
+
+function update_fuel(deltaT) {
+  changeFuel(fuel_ratio - power_ratio*deltaT*0.12, 0)
+  if (fuel_ratio <= 0) {
+    changePower(0, 200)
+  }
+}
+
+function isFuelEmpty() {
+  return fuel_ratio <= 0;
+}
+
+function isInMaxQ() {
+  return curPos>0.14 && curPos<0.23
+}
+
+function stepSimulation(prevTime) {
+  var t = getCurTime()
+  var deltaT = t - prevTime
+  update_speed(deltaT/1000)
+  update_pos(deltaT/1000)
+  update_fuel(deltaT/1000)
+  var p = path.pointAt(curPos*length)
+  rocket.center(p.x, p.y)
+  //console.log('pos' + curPos + 'speed' + curSpeed)
+  if (curPos>0.17 && curPos<0.20 && power_ratio > 0.6)  {
+    changeRocketImg('img/explosion.png')
+    alert("Explosion ! Trop de puissance au point max Q !")
+  }
+  else if (curPos >= 1) {
+    if (curStage == 4 || curStage == 3) {
+      alert("Mission réussi ! Le 3e étage est en orbite ! Bravo !")
+      if (!manual_enabled) {
+        alert("Le code de cette mission est 1957")
+      }
+    } else {
+      alert("Vous avez atteint la bonne hauteur mais pas avec le bon étage ou sans avoir largué la tour de sauvetage !")
+    }
+  } else {
+    simu_timeouts.push(setTimeout(function() {stepSimulation(t)}, 40))
+  }
+}
 
-var r1_img = canvas.image('img/r1.png').attr({x: 550, y : 0})
 
-changeFuel(0.50, 1000)
-changePower(0.6, 1000)
 
-rocket.animate(3000).during(function(pos, morph, eased){
-    var p = path.pointAt(pos * length);
-    rocket.center(p.x, p.y);
-})
 
 function changeFuel(ratio, duration) {
-  fuel_rect.animate(duration, 0, 'now').width(fuel_rect.width()*ratio);
+  fuel_ratio = Math.max(ratio, 0);
+  if (duration <= 0 ) {
+    fuel_rect.width(fuel_box.width()*fuel_ratio);
+  } else {
+    fuel_rect.animate(duration, 0, 'now').width(fuel_box.width()*fuel_ratio);
+  }
 }
 
 function changePower(ratio, duration) {
-  power_rect.animate(duration, 0, 'now').width(fuel_rect.width()*ratio);
+  power_ratio =  Math.max(ratio, 0);
+  power_ratio = Math.min(ratio, 1);
+  power_rect.animate(duration, 0, 'now').width(power_box.width()*power_ratio);
+}
+
+function changeRocketImg(imgPath) {
+ rocket_img.load(imgPath)
+ rocket.load(imgPath)
+}
+
+
+
+function changeRocketStage() {
+  curStage = (curStage < 4)?(curStage+1):4;
+  changeRocketImg('img/r' + curStage +'.png')
+  if (curStage < 4) changeFuel(1, 200)
 }
diff --git a/activity_2/toolbox.xml b/activity_2/toolbox.xml
index 8eca1b88a7cc67205cc32d1cae25ee5cd31a8a65..bf2db3afe636c338a0e1cca72f62386adc506971 100644
--- a/activity_2/toolbox.xml
+++ b/activity_2/toolbox.xml
@@ -1,30 +1,35 @@
 <xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
-  <category name="Arduino" colour="#a5745b">
-    <block type="sendtoarduino"></block>
-    <block type="turn_led">
-      <field name="val">on</field>
-    </block>
-    <block type="arduino_wait">
-      <value name="time">
-        <block type="math_number">
-          <field name="NUM">1</field>
-        </block>
-      </value>
+  <category name="Actions" colour="#a5745b">
+    <block type="enable_manual_mode"></block>
+    <block type="launch_rocket"></block>
+    <block type="engine_power_to">
+      <field name="power">50</field>
     </block>
+    <block type="separate_stage"></block>
   </category>
-  <category name="Texte" colour="#5b80a5">
-    <block type="text">
-      <field name="TEXT"></field>
-    </block>
+  <category name="Conditions" colour="#5b67a5">
+    <block type="is_fuel_empty"></block>
+    <block type="is_in_max_q"></block>
   </category>
-  <category name="Variables" colour="#a55b80" custom="VARIABLE"></category>
   <category name="Boucles" colour="#5ba55b">
-    <block type="controls_repeat_ext">
-      <value name="TIMES">
-        <shadow type="math_number">
-          <field name="NUM">10</field>
-        </shadow>
-      </value>
+    <block type="controls_whileUntil">
+      <field name="MODE">WHILE</field>
+    </block>
+  </category>
+  <category name="Logique" colour="#5b80a5">
+    <block type="controls_if"></block>
+    <block type="controls_if">
+      <mutation else="1"></mutation>
+    </block>
+    <block type="logic_compare">
+      <field name="OP">EQ</field>
+    </block>
+    <block type="logic_negate"></block>
+    <block type="logic_operation">
+      <field name="OP">AND</field>
+    </block>
+    <block type="logic_boolean">
+      <field name="BOOL">TRUE</field>
     </block>
   </category>
-</xml>
\ No newline at end of file
+</xml>
diff --git a/activity_3/img/explosion.png b/activity_3/img/explosion.png
new file mode 100644
index 0000000000000000000000000000000000000000..d547e51edd73558656c24907c3b9e516ab83b121
Binary files /dev/null and b/activity_3/img/explosion.png differ
diff --git a/activity_3/img/lander.png b/activity_3/img/lander.png
new file mode 100644
index 0000000000000000000000000000000000000000..afcfe4a15aa8ef6d1a6f17e911c020ce07637774
Binary files /dev/null and b/activity_3/img/lander.png differ
diff --git a/activity_3/img/landerjpg.jpg b/activity_3/img/landerjpg.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..749004cfa2474cf9f31149d77996c71072e363a7
Binary files /dev/null and b/activity_3/img/landerjpg.jpg differ
diff --git a/activity_3/img/r1.png b/activity_3/img/r1.png
new file mode 100644
index 0000000000000000000000000000000000000000..d6f643aaea9ef5fd99dbd2fd5a212a0826a7438d
Binary files /dev/null and b/activity_3/img/r1.png differ
diff --git a/activity_3/img/r2.png b/activity_3/img/r2.png
new file mode 100644
index 0000000000000000000000000000000000000000..96f53395f0f5055054b61504e6655c8414e858ea
Binary files /dev/null and b/activity_3/img/r2.png differ
diff --git a/activity_3/img/r3.png b/activity_3/img/r3.png
new file mode 100644
index 0000000000000000000000000000000000000000..04a923e2474a4ca31ed5e045fae9f226facd517d
Binary files /dev/null and b/activity_3/img/r3.png differ
diff --git a/activity_3/img/r4.png b/activity_3/img/r4.png
new file mode 100644
index 0000000000000000000000000000000000000000..9b30cc4ffe72c6e8c400e928d294b18db6ed3966
Binary files /dev/null and b/activity_3/img/r4.png differ
diff --git a/activity_3/index.html b/activity_3/index.html
index 206a8042d20c5df1758ce5ee3bc5cb05e4dbae02..486b94786bbcf7bd45a775dfe6b280c44e18ad3e 100644
--- a/activity_3/index.html
+++ b/activity_3/index.html
@@ -7,6 +7,7 @@
 		<!-- Import des bibliothèques js nécessaires -->
 		<script src="../res/lib/jquery.js"></script>
 		<script src="../res/lib/serial.js"></script>
+		<script src="../res/lib/svg.min.js"></script>
 
 		<script src="../res/lib/blockly/blockly_compressed.js"></script>
 		<script src="../res/lib/blockly/blocks_compressed.js"></script>
@@ -24,6 +25,16 @@
 
 
 	<body>
+		<div id="intro_modal" class="modal">
+		  <div class="modal-content">
+		    <span class="close">&times;</span>
+				<h1 style="text-align: center;">Bienvenue dans la mission 2 !</h1>
+				<p>Le carburant est chargé dans la fusée, les astronautes sont à bord et tous les voyants sont au vert... C'est l'heure du décollage !</p>
+				<p>Il faut mettre la fusée sur orbite. Pour cela, on contrôle la puissance des moteurs de la fusée. Plus ils fonctionnent de façon puissante, plus ils consomment de carburants. Heureusement, une fusée est constituée de plusieurs étages, dès qu'un étage est vide, on peut le larguer et continuer avec le carburant de celui d'après. </p>
+				<p>Attention également, dans la zone dite de "Max Q" (pression dynamique maximale), si la fusée va trop vite, elle risque d'exploser. Pensez à réduire la puissance des moteurs dans cette zone donc !</p>
+				<p style="text-align: center;"><strong>A vous de jouer ! Bon vol !</strong></p>
+		  </div>
+		</div>
 		<header id="header"></header>
 
 		<section class="mainSection">
@@ -33,7 +44,8 @@
 			</div>
 
 			<div id="toolsArea">
-				<div id="animationArea"></div>
+				<div id="animationArea">
+				</div>
 				<a class="button" id="connectButton">Connecter à la maquette</a>
 				<a class="button" id="runButton">Lancer le programme !</a>
 			</div>
diff --git a/activity_3/main-script.js b/activity_3/main-script.js
index 909fa9e89ebfbe8e57cc549973308c3ca9e9814e..911c24de36b71134cbfe1625a5ecc21e7b30ee43 100644
--- a/activity_3/main-script.js
+++ b/activity_3/main-script.js
@@ -1,3 +1,244 @@
 /* Insérer ici les fonctions spécifiques à cette activité. Elles peuvent marcher
 avec les fonctions et variables déjà définies dans 'activity_functions.js' du
 dossier 'res'.*/
+
+// Gets the modal (intiated as the intro_modal at first)
+var modal = document.getElementById("intro_modal");
+// Get the <span> element that closes the modal
+var span = document.getElementsByClassName("close")[0];
+
+// Displays the modal when DOM is Loaded
+document.addEventListener('DOMContentLoaded', event => {
+  modal.style.display = "block";
+});
+// When the user clicks on <span> (x), close the modal
+span.onclick = function() {
+  modal.style.display = "none";
+}
+// When the user clicks anywhere outside of the modal, close it
+window.onclick = function(event) {
+  if (event.target == modal) {
+    modal.style.display = "none";
+  }
+}
+
+
+
+
+
+var firstTime;
+var curSpeed;
+var curPos;
+var curStage;
+var fuel_ratio;
+var power_ratio;
+var rocketLaunched;
+var simu_timeouts = [];
+var manual_enabled;
+
+var sky_rect
+var maxq_rect
+var maxq_text
+var path
+var rocket
+var length
+
+var fuel_rect
+var fuel_box
+var fuel_text
+
+var power_rect
+var power_box
+var power_text
+
+var rocket_img
+
+
+
+
+
+var canvas = SVG().addTo('#animationArea').size(660, 510)
+
+var fuel_gradient = canvas.gradient('linear', function(add) {
+  add.stop(0, '#ff2e27')
+  add.stop(1, '#ffde00')
+})
+var power_gradient = canvas.gradient('linear', function(add) {
+  add.stop(0, '#3c8001')
+  add.stop(1, '#93f45e')
+})
+var sky_gradient = canvas.gradient('linear', function(add) {
+  add.stop(0, '#4cdaff')
+  add.stop(1, '#001b91')
+}).from(0, 1).to(0, 0)
+sky_rect = canvas.rect(500, 350).fill(sky_gradient).stroke({ width: 3, color: '#333' }).attr({x: 5, y: 5})
+maxq_rect = canvas.rect(500, 30).stroke({ width: 3, color: '#555' }).attr({x: 5, y: 220, fill:'#FFA343', })
+maxq_text = canvas.text("Zone de max Q").attr({x: 350, y:220})
+path = canvas.path("M40,353 C40,70 300,48 503,41").fill('none').stroke({width:5, color: '#ff0000'})
+rocket = canvas.image('img/r1.png').size(30, 1000).center(40,353)
+length = path.length()
+
+fuel_rect = canvas.rect(490, 50).attr({x: 160, y: 450, fill: fuel_gradient})
+fuel_box = canvas.rect(490, 50).fill('none').stroke({ width: 3, color: '#333' }).attr({x: 160, y: 450})
+fuel_text = canvas.text("Carburant de l'étage :").attr({x: 0, y: 460})
+
+power_rect = canvas.rect(490, 50).attr({x: 160, y: 395, fill: power_gradient})
+power_box = canvas.rect(490, 50).fill('none').stroke({ width: 3, color: '#333' }).attr({x: 160, y: 395})
+power_text = canvas.text("Puissance moteurs :").attr({x: 0, y: 405})
+
+rocket_img = canvas.image('img/r1.png').attr({x: 550, y : 0})
+
+function enableManual() {
+  manual_enabled = true;
+  document.addEventListener('keydown', function(event) {
+      if(event.keyCode == 38) {
+          changePower(power_ratio+0.01)
+      }
+      else if(event.keyCode == 40) {
+          changePower(power_ratio-0.01)
+      } else if (event.keyCode == 32) {
+        if (rocketLaunched) changeRocketStage()
+        else launchRocket()
+      }
+  });
+}
+
+
+
+function init_var() {
+  for (var i=0; i<simu_timeouts.length; i++) {
+  clearTimeout(simu_timeouts[i]);
+  }
+  console.log("Initialisation de la simulation")
+  firstTime = (new Date()).getTime()
+  manual_enabled = false;
+  curPos = 0;
+  curSpeed = 0;
+  curStage = 1;
+  rocketLaunched = false;
+  canvas.clear()
+  var fuel_gradient = canvas.gradient('linear', function(add) {
+    add.stop(0, '#ff2e27')
+    add.stop(1, '#ffde00')
+  })
+  var power_gradient = canvas.gradient('linear', function(add) {
+    add.stop(0, '#3c8001')
+    add.stop(1, '#93f45e')
+  })
+  var sky_gradient = canvas.gradient('linear', function(add) {
+    add.stop(0, '#4cdaff')
+    add.stop(1, '#001b91')
+  }).from(0, 1).to(0, 0)
+  sky_rect = canvas.rect(500, 350).fill(sky_gradient).stroke({ width: 3, color: '#333' }).attr({x: 5, y: 5})
+  maxq_rect = canvas.rect(500, 30).stroke({ width: 3, color: '#555' }).attr({x: 5, y: 220, fill:'#FFA343', })
+  maxq_text = canvas.text("Zone de max Q").attr({x: 350, y:220})
+  path = canvas.path("M40,353 C40,70 300,48 503,41").fill('none').stroke({width:5, color: '#ff0000'})
+  rocket = canvas.image('img/r1.png').size(30, 1000).center(40,353)
+  length = path.length()
+
+  fuel_rect = canvas.rect(490, 50).attr({x: 160, y: 450, fill: fuel_gradient})
+  fuel_box = canvas.rect(490, 50).fill('none').stroke({ width: 3, color: '#333' }).attr({x: 160, y: 450})
+  fuel_text = canvas.text("Carburant de l'étage :").attr({x: 0, y: 460})
+
+  power_rect = canvas.rect(490, 50).attr({x: 160, y: 395, fill: power_gradient})
+  power_box = canvas.rect(490, 50).fill('none').stroke({ width: 3, color: '#333' }).attr({x: 160, y: 395})
+  power_text = canvas.text("Puissance moteurs :").attr({x: 0, y: 405})
+
+  rocket_img = canvas.image('img/r1.png').attr({x: 550, y : 0})
+  changeFuel(1, 0)
+  changePower(0, 0)
+  stepSimulation(getCurTime())
+}
+
+function launchRocket() {
+  rocketLaunched = true;
+}
+
+function getCurTime() {
+  return(new Date()).getTime() - firstTime;
+}
+
+function update_speed(deltaT) {
+  if (curPos <= 0 && curSpeed < 0 && power_ratio<=0.5) curSpeed = 0
+  else if (!rocketLaunched) curSpeed = 0
+  else curSpeed = curSpeed + (power_ratio-0.5)*deltaT*0.01
+
+}
+
+function update_pos(deltaT) {
+  curPos = Math.max(curPos + curSpeed*deltaT, 0);
+
+}
+
+function update_fuel(deltaT) {
+  changeFuel(fuel_ratio - power_ratio*deltaT*0.12, 0)
+  if (fuel_ratio <= 0) {
+    changePower(0, 200)
+  }
+}
+
+function isFuelEmpty() {
+  return fuel_ratio <= 0;
+}
+
+function isInMaxQ() {
+  return curPos>0.14 && curPos<0.23
+}
+
+function stepSimulation(prevTime) {
+  var t = getCurTime()
+  var deltaT = t - prevTime
+  update_speed(deltaT/1000)
+  update_pos(deltaT/1000)
+  update_fuel(deltaT/1000)
+  var p = path.pointAt(curPos*length)
+  rocket.center(p.x, p.y)
+  //console.log('pos' + curPos + 'speed' + curSpeed)
+  if (curPos>0.17 && curPos<0.20 && power_ratio > 0.6)  {
+    changeRocketImg('img/explosion.png')
+    alert("Explosion ! Trop de puissance au point max Q !")
+  }
+  else if (curPos >= 1) {
+    if (curStage == 4 || curStage == 3) {
+      alert("Mission réussi ! Le 3e étage est en orbite ! Bravo !")
+      if (!manual_enabled) {
+        alert("Le code de cette mission est 1957")
+      }
+    } else {
+      alert("Vous avez atteint la bonne hauteur mais pas avec le bon étage ou sans avoir largué la tour de sauvetage !")
+    }
+  } else {
+    simu_timeouts.push(setTimeout(function() {stepSimulation(t)}, 40))
+  }
+}
+
+
+
+
+function changeFuel(ratio, duration) {
+  fuel_ratio = Math.max(ratio, 0);
+  if (duration <= 0 ) {
+    fuel_rect.width(fuel_box.width()*fuel_ratio);
+  } else {
+    fuel_rect.animate(duration, 0, 'now').width(fuel_box.width()*fuel_ratio);
+  }
+}
+
+function changePower(ratio, duration) {
+  power_ratio =  Math.max(ratio, 0);
+  power_ratio = Math.min(ratio, 1);
+  power_rect.animate(duration, 0, 'now').width(power_box.width()*power_ratio);
+}
+
+function changeRocketImg(imgPath) {
+ rocket_img.load(imgPath)
+ rocket.load(imgPath)
+}
+
+
+
+function changeRocketStage() {
+  curStage = (curStage < 4)?(curStage+1):4;
+  changeRocketImg('img/r' + curStage +'.png')
+  if (curStage < 4) changeFuel(1, 200)
+}
diff --git a/activity_3/toolbox.xml b/activity_3/toolbox.xml
index 8eca1b88a7cc67205cc32d1cae25ee5cd31a8a65..bf2db3afe636c338a0e1cca72f62386adc506971 100644
--- a/activity_3/toolbox.xml
+++ b/activity_3/toolbox.xml
@@ -1,30 +1,35 @@
 <xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
-  <category name="Arduino" colour="#a5745b">
-    <block type="sendtoarduino"></block>
-    <block type="turn_led">
-      <field name="val">on</field>
-    </block>
-    <block type="arduino_wait">
-      <value name="time">
-        <block type="math_number">
-          <field name="NUM">1</field>
-        </block>
-      </value>
+  <category name="Actions" colour="#a5745b">
+    <block type="enable_manual_mode"></block>
+    <block type="launch_rocket"></block>
+    <block type="engine_power_to">
+      <field name="power">50</field>
     </block>
+    <block type="separate_stage"></block>
   </category>
-  <category name="Texte" colour="#5b80a5">
-    <block type="text">
-      <field name="TEXT"></field>
-    </block>
+  <category name="Conditions" colour="#5b67a5">
+    <block type="is_fuel_empty"></block>
+    <block type="is_in_max_q"></block>
   </category>
-  <category name="Variables" colour="#a55b80" custom="VARIABLE"></category>
   <category name="Boucles" colour="#5ba55b">
-    <block type="controls_repeat_ext">
-      <value name="TIMES">
-        <shadow type="math_number">
-          <field name="NUM">10</field>
-        </shadow>
-      </value>
+    <block type="controls_whileUntil">
+      <field name="MODE">WHILE</field>
+    </block>
+  </category>
+  <category name="Logique" colour="#5b80a5">
+    <block type="controls_if"></block>
+    <block type="controls_if">
+      <mutation else="1"></mutation>
+    </block>
+    <block type="logic_compare">
+      <field name="OP">EQ</field>
+    </block>
+    <block type="logic_negate"></block>
+    <block type="logic_operation">
+      <field name="OP">AND</field>
+    </block>
+    <block type="logic_boolean">
+      <field name="BOOL">TRUE</field>
     </block>
   </category>
-</xml>
\ No newline at end of file
+</xml>
diff --git a/activity_4/index.html b/activity_4/index.html
index 456aecc6009f1d00f23a81fd1f01e1e88a4430ed..21699fecf2a9ec0bfc290f2aec3575065a0f83eb 100644
--- a/activity_4/index.html
+++ b/activity_4/index.html
@@ -58,6 +58,7 @@
 						<p>Il faut désormais trouver un chemin téléphonique jusqu'au bureau du président, à Washington.</p>
 						<p>Il faut relier les villes entre elles pour trouver le chemin le plus court entre les villes. Mais attention, la liaison entre Louisville et Washington est défectueuse. Il faut prévoir une autre route si elle ne marche pas (utiliser une condition "si... sinon".)</p>
 						<p style="text-align: center;"><strong>A vous de jouer ! Utilisez les blocs correspondant à ces actions pour mener à bien cette mission !</strong></p>
+						<button onclick="displayConsignes('desc_3')">Passer à la partie suivante</button>
 					</div>
 					<div id ="desc_3" class="consignes">
 						<h3 style="text-align: center;">Troisième partie : puzzle, trouver le numéro du président !</h3>
diff --git a/activity_4/main-script.js b/activity_4/main-script.js
index e3924434b4011a797f01ea6ec3d95aed896c3949..db485796a89ed382240924c686bf11b5202c2d59 100644
--- a/activity_4/main-script.js
+++ b/activity_4/main-script.js
@@ -12,6 +12,7 @@ function init_var() {
   camera_setup = false;
   moon_signal_activated = false;
   hatch_opened = false;
+  sendString('IO_4_1;IO_5_1;IO_6_1;IO_7_1;IO_8_1;IO_9_1;IO_10_1;IO_14_1;IO_15_1;IO_16_1;IO_18_1;IO_19_1;IO_20_1;IO_21_1;');
 
 }
 
diff --git a/activity_4/toolbox.xml b/activity_4/toolbox.xml
index f5a3cd8ccd57afc1828afe95ef2c79d19edcfc5a..93f0e7651f8d1934760538d25d65ab5e51d7bfe9 100644
--- a/activity_4/toolbox.xml
+++ b/activity_4/toolbox.xml
@@ -3,6 +3,18 @@
     <block type="setup_camera_module"></block>
     <block type="activate_camera"></block>
     <block type="open_hatch"></block>
+    <block type="turn_io">
+      <value name="IO">
+        <shadow type="math_number">
+          <field name="NUM">4</field>
+        </shadow>
+      </value>
+      <value name="VAL">
+        <shadow type="math_number">
+          <field name="NUM">1</field>
+        </shadow>
+      </value>
+    </block>
     <block type="activate_moon_signal"></block>
   </category>
   <category name="Partie 2">
@@ -96,4 +108,4 @@
     </block>
   </category>
   <category name="Variables" colour="#a55b80" custom="VARIABLE"></category>
-</xml>
\ No newline at end of file
+</xml>
diff --git a/android-icon-144x144.png b/android-icon-144x144.png
new file mode 100644
index 0000000000000000000000000000000000000000..4857c79a788dfe5cddb3837e0ba3dc2a4694b09c
Binary files /dev/null and b/android-icon-144x144.png differ
diff --git a/android-icon-192x192.png b/android-icon-192x192.png
new file mode 100644
index 0000000000000000000000000000000000000000..da24b4d411f8a7fffd602358c20f91063efcd150
Binary files /dev/null and b/android-icon-192x192.png differ
diff --git a/android-icon-36x36.png b/android-icon-36x36.png
new file mode 100644
index 0000000000000000000000000000000000000000..61030473eef86c1885644fcff313d1eea52fcd15
Binary files /dev/null and b/android-icon-36x36.png differ
diff --git a/android-icon-48x48.png b/android-icon-48x48.png
new file mode 100644
index 0000000000000000000000000000000000000000..84bde4035b1549e72f52ec7cf11587595bc1b9cd
Binary files /dev/null and b/android-icon-48x48.png differ
diff --git a/android-icon-72x72.png b/android-icon-72x72.png
new file mode 100644
index 0000000000000000000000000000000000000000..7029d3bda42366abe8416d5733a034bd74e5b129
Binary files /dev/null and b/android-icon-72x72.png differ
diff --git a/android-icon-96x96.png b/android-icon-96x96.png
new file mode 100644
index 0000000000000000000000000000000000000000..b301f8a3f5b2fbb0e8458a8b4bcf5aecd0acd342
Binary files /dev/null and b/android-icon-96x96.png differ
diff --git a/apple-icon-114x114.png b/apple-icon-114x114.png
new file mode 100644
index 0000000000000000000000000000000000000000..f1c2f8dff0fc57bbeb1f669e741be9dd3733cf09
Binary files /dev/null and b/apple-icon-114x114.png differ
diff --git a/apple-icon-120x120.png b/apple-icon-120x120.png
new file mode 100644
index 0000000000000000000000000000000000000000..a836fe61bab3530534be8cba193322696def154c
Binary files /dev/null and b/apple-icon-120x120.png differ
diff --git a/apple-icon-144x144.png b/apple-icon-144x144.png
new file mode 100644
index 0000000000000000000000000000000000000000..4857c79a788dfe5cddb3837e0ba3dc2a4694b09c
Binary files /dev/null and b/apple-icon-144x144.png differ
diff --git a/apple-icon-152x152.png b/apple-icon-152x152.png
new file mode 100644
index 0000000000000000000000000000000000000000..3226559b21cf5ec6b3732f768d847eeba29c0fdb
Binary files /dev/null and b/apple-icon-152x152.png differ
diff --git a/apple-icon-180x180.png b/apple-icon-180x180.png
new file mode 100644
index 0000000000000000000000000000000000000000..63aca65c0f047034a3c8dd307bb6ce6db467ba6b
Binary files /dev/null and b/apple-icon-180x180.png differ
diff --git a/apple-icon-57x57.png b/apple-icon-57x57.png
new file mode 100644
index 0000000000000000000000000000000000000000..4d7bc4c71eb172dc22cc694c98652e6d1f8bccb8
Binary files /dev/null and b/apple-icon-57x57.png differ
diff --git a/apple-icon-60x60.png b/apple-icon-60x60.png
new file mode 100644
index 0000000000000000000000000000000000000000..837a1acb918d5661d903f06829b4497db339c365
Binary files /dev/null and b/apple-icon-60x60.png differ
diff --git a/apple-icon-72x72.png b/apple-icon-72x72.png
new file mode 100644
index 0000000000000000000000000000000000000000..7029d3bda42366abe8416d5733a034bd74e5b129
Binary files /dev/null and b/apple-icon-72x72.png differ
diff --git a/apple-icon-76x76.png b/apple-icon-76x76.png
new file mode 100644
index 0000000000000000000000000000000000000000..2a89c68034efb232e2b59e27045ade7ad7122b51
Binary files /dev/null and b/apple-icon-76x76.png differ
diff --git a/apple-icon-precomposed.png b/apple-icon-precomposed.png
new file mode 100644
index 0000000000000000000000000000000000000000..686ea5f0b82120e101e342965b93995e24e0e46e
Binary files /dev/null and b/apple-icon-precomposed.png differ
diff --git a/apple-icon.png b/apple-icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..686ea5f0b82120e101e342965b93995e24e0e46e
Binary files /dev/null and b/apple-icon.png differ
diff --git a/arduino/act4/act4.ino b/arduino/act4/act4.ino
index 9f38b124c6c293926ec11a7447d325161b4af3d7..8e9e7ee5d83eb2deede01cddde2dcb2827a88010 100644
--- a/arduino/act4/act4.ino
+++ b/arduino/act4/act4.ino
@@ -4,47 +4,47 @@
 
 class Mp3Notify
 {
-public:
-  static void PrintlnSourceAction(DfMp3_PlaySources source, const char* action)
-  {
-    if (source & DfMp3_PlaySources_Sd) 
+  public:
+    static void PrintlnSourceAction(DfMp3_PlaySources source, const char* action)
     {
+      if (source & DfMp3_PlaySources_Sd)
+      {
         Serial.print("SD Card, ");
+      }
+      if (source & DfMp3_PlaySources_Usb)
+      {
+        Serial.print("USB Disk, ");
+      }
+      if (source & DfMp3_PlaySources_Flash)
+      {
+        Serial.print("Flash, ");
+      }
+      Serial.println(action);
     }
-    if (source & DfMp3_PlaySources_Usb) 
+    static void OnError(uint16_t errorCode)
     {
-        Serial.print("USB Disk, ");
+      // see DfMp3_Error for code meaning
+      Serial.println();
+      Serial.print("Com Error ");
+      Serial.println(errorCode);
     }
-    if (source & DfMp3_PlaySources_Flash) 
+    static void OnPlayFinished(DfMp3_PlaySources source, uint16_t track)
     {
-        Serial.print("Flash, ");
+      Serial.print("Play finished for #");
+      Serial.println(track);
+    }
+    static void OnPlaySourceOnline(DfMp3_PlaySources source)
+    {
+      PrintlnSourceAction(source, "online");
+    }
+    static void OnPlaySourceInserted(DfMp3_PlaySources source)
+    {
+      PrintlnSourceAction(source, "inserted");
+    }
+    static void OnPlaySourceRemoved(DfMp3_PlaySources source)
+    {
+      PrintlnSourceAction(source, "removed");
     }
-    Serial.println(action);
-  }
-  static void OnError(uint16_t errorCode)
-  {
-    // see DfMp3_Error for code meaning
-    Serial.println();
-    Serial.print("Com Error ");
-    Serial.println(errorCode);
-  }
-  static void OnPlayFinished(DfMp3_PlaySources source, uint16_t track)
-  {
-    Serial.print("Play finished for #");
-    Serial.println(track);  
-  }
-  static void OnPlaySourceOnline(DfMp3_PlaySources source)
-  {
-    PrintlnSourceAction(source, "online");
-  }
-  static void OnPlaySourceInserted(DfMp3_PlaySources source)
-  {
-    PrintlnSourceAction(source, "inserted");
-  }
-  static void OnPlaySourceRemoved(DfMp3_PlaySources source)
-  {
-    PrintlnSourceAction(source, "removed");
-  }
 };
 
 /**
@@ -85,13 +85,31 @@ void setup() {
   pinMode(20, OUTPUT);
   pinMode(21, OUTPUT);
   pinMode(RING_PIN, OUTPUT);
+  digitalWrite(2, 1);
+  delay(2000);
+  digitalWrite(2, 0);
+  digitalWrite(3, 1);
+  digitalWrite(4, 1);
+  digitalWrite(5, 1);
+  digitalWrite(6, 1);
+  digitalWrite(7, 1);
+  digitalWrite(8, 1);
+  digitalWrite(9, 1);
+  digitalWrite(10, 1);
+  digitalWrite(14, 1);
+  digitalWrite(15, 1);
+  digitalWrite(16, 1);
+  digitalWrite(18, 1);
+  digitalWrite(19, 1);
+  digitalWrite(20, 1);
+  digitalWrite(21, 1);
   mp3.begin();
   mp3.setVolume(24);
   while (!Serial) {
     ;
   }
   Serial.begin(9600);
-  Serial.print("Arduino connected and answering");
+  Serial.println("Arduino connected and answering");
   delay(1000);
   Serial.flush();
 }
@@ -117,19 +135,30 @@ void ringTrack(int n, uint16_t duration) {
   delay(4000);
   digitalWrite(RING_PIN, LOW);
   delay(500);
-  mp3.playMp3FolderTrack(n);
+  if (n == 777) {
+    mp3.playMp3FolderTrack(777);
+  } else {
+    int t = (int) random(1, 6);
+    Serial.println(t);
+    if (t < 3) {
+      mp3.playMp3FolderTrack(1);
+    } else {
+      mp3.playMp3FolderTrack(2);
+    }
+  }
+  
   waitMilliseconds(duration);
 }
 
 void waitMilliseconds(uint16_t msWait)
 {
   uint32_t start = millis();
-  
+
   while ((millis() - start) < msWait)
   {
-    // calling mp3.loop() periodically allows for notifications 
+    // calling mp3.loop() periodically allows for notifications
     // to be handled without interrupts
-    mp3.loop(); 
+    mp3.loop();
     delay(1);
   }
 }
@@ -141,8 +170,8 @@ void runCommand(String command) {
   String id = command.substring(0, curIndex);
   Serial.print(id);
   String args[5] = {"0", "0", "0", "0", "0"}; //Max 5 args
-  for (int i = 0; i<5; i++) {
-    int nextIndex = command.indexOf('_', curIndex+1);
+  for (int i = 0; i < 5; i++) {
+    int nextIndex = command.indexOf('_', curIndex + 1);
     args[i] = command.substring(curIndex + 1, nextIndex);
     Serial.print(args[i]);
     curIndex = nextIndex;
@@ -152,7 +181,7 @@ void runCommand(String command) {
     }
   }
 
-  
+
   //Lancement des diverses commandes
   if (id == "IO") {
     turnIO(args[0].toInt(), args[1].toInt());
@@ -161,8 +190,8 @@ void runCommand(String command) {
   } else if (id == "RING") {
     ringTrack(args[0].toInt(), 10000);
   }
-  
-   
+
+
 }
 
 /* FONCTIONS METIER */
diff --git a/browserconfig.xml b/browserconfig.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c5541482230075d4b4800ebbb7ac42fad29e5133
--- /dev/null
+++ b/browserconfig.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="utf-8"?>
+<browserconfig><msapplication><tile><square70x70logo src="/ms-icon-70x70.png"/><square150x150logo src="/ms-icon-150x150.png"/><square310x310logo src="/ms-icon-310x310.png"/><TileColor>#ffffff</TileColor></tile></msapplication></browserconfig>
\ No newline at end of file
diff --git a/doc/Atelier 2.docx b/doc/Atelier 2.docx
new file mode 100644
index 0000000000000000000000000000000000000000..4285fdad287494280432550a95eb508e70751e10
Binary files /dev/null and b/doc/Atelier 2.docx differ
diff --git a/favicon-16x16.png b/favicon-16x16.png
new file mode 100644
index 0000000000000000000000000000000000000000..0ec96218e6894ff2330526fb063f3e1a722f9e47
Binary files /dev/null and b/favicon-16x16.png differ
diff --git a/favicon-32x32.png b/favicon-32x32.png
new file mode 100644
index 0000000000000000000000000000000000000000..f3b61221ca75ad4cf0f4e8129d99792efe8eb71a
Binary files /dev/null and b/favicon-32x32.png differ
diff --git a/favicon-96x96.png b/favicon-96x96.png
new file mode 100644
index 0000000000000000000000000000000000000000..b301f8a3f5b2fbb0e8458a8b4bcf5aecd0acd342
Binary files /dev/null and b/favicon-96x96.png differ
diff --git a/favicon.ico b/favicon.ico
new file mode 100644
index 0000000000000000000000000000000000000000..fe65c22fc22798b110e82aa2a81f4ddf74b45da0
Binary files /dev/null and b/favicon.ico differ
diff --git a/manifest.json b/manifest.json
new file mode 100644
index 0000000000000000000000000000000000000000..013d4a6a53334fae827a32824eaf51a889396514
--- /dev/null
+++ b/manifest.json
@@ -0,0 +1,41 @@
+{
+ "name": "App",
+ "icons": [
+  {
+   "src": "\/android-icon-36x36.png",
+   "sizes": "36x36",
+   "type": "image\/png",
+   "density": "0.75"
+  },
+  {
+   "src": "\/android-icon-48x48.png",
+   "sizes": "48x48",
+   "type": "image\/png",
+   "density": "1.0"
+  },
+  {
+   "src": "\/android-icon-72x72.png",
+   "sizes": "72x72",
+   "type": "image\/png",
+   "density": "1.5"
+  },
+  {
+   "src": "\/android-icon-96x96.png",
+   "sizes": "96x96",
+   "type": "image\/png",
+   "density": "2.0"
+  },
+  {
+   "src": "\/android-icon-144x144.png",
+   "sizes": "144x144",
+   "type": "image\/png",
+   "density": "3.0"
+  },
+  {
+   "src": "\/android-icon-192x192.png",
+   "sizes": "192x192",
+   "type": "image\/png",
+   "density": "4.0"
+  }
+ ]
+}
\ No newline at end of file
diff --git a/ms-icon-144x144.png b/ms-icon-144x144.png
new file mode 100644
index 0000000000000000000000000000000000000000..4857c79a788dfe5cddb3837e0ba3dc2a4694b09c
Binary files /dev/null and b/ms-icon-144x144.png differ
diff --git a/ms-icon-150x150.png b/ms-icon-150x150.png
new file mode 100644
index 0000000000000000000000000000000000000000..b3800506cc25a45c561cf83e4ec9515f8e174820
Binary files /dev/null and b/ms-icon-150x150.png differ
diff --git a/ms-icon-310x310.png b/ms-icon-310x310.png
new file mode 100644
index 0000000000000000000000000000000000000000..175744b833559657f460dc607755863c67076863
Binary files /dev/null and b/ms-icon-310x310.png differ
diff --git a/ms-icon-70x70.png b/ms-icon-70x70.png
new file mode 100644
index 0000000000000000000000000000000000000000..d9c3048f0e1a3ffcf4cdf76bc60a1384661ecbfa
Binary files /dev/null and b/ms-icon-70x70.png differ
diff --git a/res/activity_functions.js b/res/activity_functions.js
index 69e6cf970f2d473b978d93c3cc5c194b53b0c033..24178e3d7035ec1bfb3147a097746379d039b932 100644
--- a/res/activity_functions.js
+++ b/res/activity_functions.js
@@ -3,18 +3,31 @@ var blocklyArea = document.getElementById('blocklyArea');
 var connectButton = document.getElementById('connectButton');
 var runButton = document.getElementById('runButton');
 
+Blockly.JavaScript.STATEMENT_PREFIX = 'highlightBlock(%1);\n';
+Blockly.JavaScript.addReservedWords('highlightBlock');
+
 var receivedMsg = "";
 
 var port;
 let textEncoder = new TextEncoder();
 
 
+function highlightBlock(id) {
+  workspace.highlightBlock(id);
+}
+
 //Lance le code tel que rentré par le joueur
 function runCode() {
 	init_var();
 	var code = Blockly.JavaScript.workspaceToCode(workspace); //On récupère un code javascript
+	console.log(code)
 	var myInterpreter = new Interpreter(code, initApi); //Intanciation d'une VM avec fonctions réécrites
-	myInterpreter.run(); //On lance le code de l'utilisateur dans la VM
+	function nextStep() {
+  	if (myInterpreter.step()) {
+    	setTimeout(nextStep, 10);
+  	}
+	}
+	nextStep();
   //Il est possible de lancer le code de façon séquencielle
 }
 
@@ -72,6 +85,42 @@ function changeVar(variable, value) {
 
 //Interprétation des commandes par l'utiliseur (redéfinition des fonctions avec IO)
 function initApi(interpreter, scope) {
+  var wrapper = function(text) {
+		return enableManual();
+	};
+	interpreter.setProperty(scope, 'enableManual',
+	interpreter.createNativeFunction(wrapper));
+
+	var wrapper = function(text) {
+		return changePower(arguments.length ? text : '');
+	};
+	interpreter.setProperty(scope, 'changePower',
+	interpreter.createNativeFunction(wrapper));
+
+	var wrapper = function(text) {
+		return isInMaxQ();
+	};
+	interpreter.setProperty(scope, 'isInMaxQ',
+	interpreter.createNativeFunction(wrapper));
+
+	var wrapper = function(text) {
+		return isFuelEmpty();
+	};
+	interpreter.setProperty(scope, 'isFuelEmpty',
+	interpreter.createNativeFunction(wrapper));
+
+	var wrapper = function(text) {
+		return changeRocketStage();
+	};
+	interpreter.setProperty(scope, 'changeRocketStage',
+	interpreter.createNativeFunction(wrapper));
+
+	var wrapper = function(text) {
+		return launchRocket();
+	};
+	interpreter.setProperty(scope, 'launchRocket',
+	interpreter.createNativeFunction(wrapper));
+
 	var wrapper = function(text) {
 		return displayConsignes(arguments.length ? text : '');
 	};
@@ -110,6 +159,12 @@ function initApi(interpreter, scope) {
 	};
 	interpreter.setProperty(scope, 'waitForMessageFromArduino',
 	interpreter.createNativeFunction(wrapper));
+	// Add an API function for highlighting blocks.
+  var wrapper = function(id) {
+    return workspace.highlightBlock(id);
+  };
+  interpreter.setProperty(scope, 'highlightBlock',
+      interpreter.createNativeFunction(wrapper));
 }
 
 
@@ -120,6 +175,7 @@ function initApi(interpreter, scope) {
 
 //Instanciation de la liaison série à la fin du chargement de la page
 document.addEventListener('DOMContentLoaded', event => {
+	runButton.addEventListener('click', runCode);
   function connect() {
     console.log('Connecting to ' + port.device_.productName + '...');
     port.connect().then(() => {
@@ -130,7 +186,6 @@ document.addEventListener('DOMContentLoaded', event => {
 			connectButton.style.border = '3px solid #801C0D';
 			runButton.style.background = 'linear-gradient(to bottom, #77B55B 5%, #568241 100%)';
 			runButton.style.border = '3px solid #476B36';
-			runButton.addEventListener('click', runCode);
       port.onReceive = data => {
         let textDecoder = new TextDecoder();
         receivedMsg = textDecoder.decode(data);
diff --git a/res/blocks/arduino_blocks_def.js b/res/blocks/arduino_blocks_def.js
index f9369178047c8e229ecd78d52377937a610439d2..092d8e89f8c252de77e95a84cc0b8b28951dcf6e 100644
--- a/res/blocks/arduino_blocks_def.js
+++ b/res/blocks/arduino_blocks_def.js
@@ -58,6 +58,86 @@ Blockly.Blocks['turn_io'] = {
 };
 
 
+/* ACT 2*/
+
+
+Blockly.Blocks['launch_rocket'] = {
+  init: function() {
+    this.appendDummyInput()
+        .appendField("Lancer la fusée");
+    this.setPreviousStatement(true, null);
+    this.setNextStatement(true, null);
+    this.setColour(0);
+ this.setTooltip("");
+ this.setHelpUrl("");
+  }
+};
+
+Blockly.Blocks['engine_power_to'] = {
+  init: function() {
+    this.appendDummyInput()
+        .appendField("Mettre la puissance des moteurs à")
+        .appendField(new Blockly.FieldNumber(50, 0, 100, 1), "power");
+    this.setPreviousStatement(true, null);
+    this.setNextStatement(true, null);
+    this.setColour(0);
+ this.setTooltip("Contrôle la puissance des moteurs");
+ this.setHelpUrl("");
+  }
+};
+
+Blockly.Blocks['separate_stage'] = {
+  init: function() {
+    this.appendDummyInput()
+        .appendField("Séparer l'étage courant ");
+    this.setPreviousStatement(true, null);
+    this.setNextStatement(true, null);
+    this.setColour(0);
+ this.setTooltip("Séparer l'étage utilisé de la fusée");
+ this.setHelpUrl("");
+  }
+};
+
+Blockly.Blocks['is_fuel_empty'] = {
+  init: function() {
+    this.appendDummyInput()
+        .appendField("il n'y a plus de carburant dans l'étage");
+    this.setOutput(true, "Boolean");
+    this.setColour(230);
+ this.setTooltip("");
+ this.setHelpUrl("");
+  }
+};
+
+Blockly.Blocks['is_in_max_q'] = {
+  init: function() {
+    this.appendDummyInput()
+        .appendField("on est dans la zone de max Q");
+    this.setOutput(true, "Boolean");
+    this.setColour(230);
+ this.setTooltip("Vérifie si on est dans la zone de pression maximale");
+ this.setHelpUrl("");
+  }
+};
+
+Blockly.Blocks['enable_manual_mode'] = {
+  init: function() {
+    this.appendDummyInput()
+        .appendField("Lancer la simulation en mode manuel");
+    this.setColour(0);
+ this.setTooltip("");
+ this.setHelpUrl("");
+  }
+};
+
+
+
+
+
+
+
+
+
 
 
 /* ACT 4 */
@@ -78,7 +158,7 @@ Blockly.Blocks['establish_telecoms'] = {
   init: function() {
     this.appendDummyInput()
         .appendField("Etablir la communication")
-        .appendField(new Blockly.FieldDropdown([["Houston - Amarillo - Rapid City","1"], ["Houston - Little Rock","OPTIONNAME"], ["Houston - Jacksonville","OPTIONNAME"], ["Little Rock - Norman","OPTIONNAME"], ["Little Rock - Atlanta - Jacksonville","OPTIONNAME"], ["Norman - Rapid City","OPTIONNAME"], ["Norman - Louisville","OPTIONNAME"], ["Louisville - Chicago","OPTIONNAME"], ["Louisville - Washington","OPTIONNAME"], ["Louisville - Richmond","OPTIONNAME"], ["Chicago - Rapid City","OPTIONNAME"], ["Chicago - Bufallo","OPTIONNAME"], ["Bufallo - Washington","OPTIONNAME"], ["Jacksonville - Richmond","OPTIONNAME"]]), "val");
+        .appendField(new Blockly.FieldDropdown([["Houston - Amarillo - Rapid City","9"], ["Houston - Little Rock","10"], ["Houston - Jacksonville","14"], ["Little Rock - Norman","16"], ["Little Rock - Atlanta - Jacksonville","18"], ["Norman - Rapid City","4"], ["Norman - Louisville","15"], ["Louisville - Chicago","8"], ["Louisville - Washington","7"], ["Louisville - Richmond","19"], ["Chicago - Rapid City","21"], ["Chicago - Bufallo","6"], ["Bufallo - Washington","5"], ["Jacksonville - Richmond","20"]]), "val");
     this.setPreviousStatement(true, null);
     this.setNextStatement(true, null);
     this.setColour(0);
diff --git a/res/blocks/arduino_blocks_gen.js b/res/blocks/arduino_blocks_gen.js
index 7919e77fcb92280cd1913b03eadbe88f257e57fe..291df2d15b51e53876ff92ebd9ccd5823ffb70cd 100644
--- a/res/blocks/arduino_blocks_gen.js
+++ b/res/blocks/arduino_blocks_gen.js
@@ -32,13 +32,59 @@ Blockly.JavaScript['turn_io'] = function(block) {
 
 
 
+
+/* ACTIVITE 2 */
+
+Blockly.JavaScript['launch_rocket'] = function(block) {
+  var code = 'launchRocket();\n';
+  return code;
+};
+
+Blockly.JavaScript['engine_power_to'] = function(block) {
+  var number_power = block.getFieldValue('power');
+  number_power = number_power/100.0;
+  var code = 'changePower('+  number_power +', 200);\n';
+  return code;
+};
+
+Blockly.JavaScript['separate_stage'] = function(block) {
+  var code = 'changeRocketStage();\n';
+  return code;
+};
+
+Blockly.JavaScript['is_fuel_empty'] = function(block) {
+  // TODO: Assemble JavaScript into code variable.
+  var code = 'isFuelEmpty()';
+  // TODO: Change ORDER_NONE to the correct strength.
+  return [code, Blockly.JavaScript.ORDER_NONE];
+};
+
+Blockly.JavaScript['is_in_max_q'] = function(block) {
+  // TODO: Assemble JavaScript into code variable.
+  var code = 'isInMaxQ()';
+  // TODO: Change ORDER_NONE to the correct strength.
+  return [code, Blockly.JavaScript.ORDER_NONE];
+};
+
+Blockly.JavaScript['enable_manual_mode'] = function(block) {
+  // TODO: Assemble JavaScript into code variable.
+
+  var code = 'enableManual();\n';
+  return code;
+};
+
+
+
+
+
+
 /* ACTIVITE 4 */
 
 Blockly.JavaScript['activate_camera'] = function(block) {
   // TODO: Assemble JavaScript into code variable.
   var code = 'alert("Impossible de démarrer la diffusion ! Quelque chose ne va pas ! Le SAS est ouvert ? La caméra est en place ? Le signal est envoyé vers la Terre ?");';
   if (hatch_opened && moon_signal_activated && camera_setup) {
-    code = ' sendString("IO_3_1;");\n displayConsignes("desc_2"); \n';
+    code = ' sendString("IO_3_0;");\n displayConsignes("desc_2"); \n';
   }
   return code;
 };
@@ -69,7 +115,7 @@ Blockly.JavaScript['activate_moon_signal'] = function(block) {
 Blockly.JavaScript['establish_telecoms'] = function(block) {
   // TODO: Assemble JavaScript into code variable.
   var dropdown_val = block.getFieldValue('val');
-  var code = 'alert('+ dropdown_val + ');\n';
+  var code = 'sendString("IO_'+ dropdown_val + '_0;");\n';
   return code;
 };
 
@@ -92,7 +138,7 @@ Blockly.JavaScript['count_letter_in_string'] = function(block) {
 
 Blockly.JavaScript['is_telecom_working'] = function(block) {
   // TODO: Assemble JavaScript into code variable.
-  var code = false;
+  var code = 'false';
   // TODO: Change ORDER_NONE to the correct strength.
   return [code, Blockly.JavaScript.ORDER_NONE];
 };