{"action":"opened","issue":{"url":"https://api.github.com/repos/farmerbriantee/AgOpenGPS/issues/2","repository_url":"https://api.github.com/repos/farmerbriantee/AgOpenGPS","labels_url":"https://api.github.com/repos/farmerbriantee/AgOpenGPS/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/farmerbriantee/AgOpenGPS/issues/2/comments","events_url":"https://api.github.com/repos/farmerbriantee/AgOpenGPS/issues/2/events","html_url":"https://github.com/farmerbriantee/AgOpenGPS/issues/2","id":186075426,"number":2,"title":"The sketch ","user":{"login":"aortner","id":23136635,"avatar_url":"https://avatars.githubusercontent.com/u/23136635?v=3","gravatar_id":"","url":"https://api.github.com/users/aortner","html_url":"https://github.com/aortner","followers_url":"https://api.github.com/users/aortner/followers","following_url":"https://api.github.com/users/aortner/following{/other_user}","gists_url":"https://api.github.com/users/aortner/gists{/gist_id}","starred_url":"https://api.github.com/users/aortner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aortner/subscriptions","organizations_url":"https://api.github.com/users/aortner/orgs","repos_url":"https://api.github.com/users/aortner/repos","events_url":"https://api.github.com/users/aortner/events{/privacy}","received_events_url":"https://api.github.com/users/aortner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-29T12:14:03Z","updated_at":"2016-10-29T12:14:03Z","closed_at":null,"body":"// Arduino Cerea Boom Control\r\n// (C) 2016 by Andreas Ortner - office@gh-ortner.com\r\n// \r\n\r\n\r\nString cmd;\r\nchar nextChar;\r\nString teilbreite;\r\nint anztb ;\r\nint i;\r\n\r\nvoid setup() {\r\n  Serial.begin(9600);\r\n  pinMode(2, OUTPUT);   //boom 1 Pin 2\r\n  pinMode(3, OUTPUT);\r\n  pinMode(4, OUTPUT);\r\n  pinMode(5, OUTPUT);\r\n  pinMode(6, OUTPUT);\r\n  pinMode(7, OUTPUT);\r\n  pinMode(8, OUTPUT);  // boom 7\r\n  pinMode(9, OUTPUT);  // reley8 pin 9 hidraulic command\r\n\r\n  digitalWrite(2, HIGH);  // all Ports  0 = HIGH \r\n  digitalWrite(3, HIGH);\r\n  digitalWrite(4, HIGH);\r\n  digitalWrite(5, HIGH);\r\n  digitalWrite(6, HIGH);\r\n  digitalWrite(7, HIGH);\r\n  digitalWrite(8, HIGH);\r\n  digitalWrite(9, HIGH);\r\n}\r\n\r\nvoid loop()\r\n{\r\n  cmd = \"\";   // String clean\r\n  ser();      // read serial\r\n  \r\n  if (cmd.startsWith(\"@CEREA;\")) {    // if  Cerea start with boom control\r\n    cerea();\r\n  }\r\n  if (cmd.startsWith(\"@HIDRAU\")) {    //if hidrau start with hidrau\r\n    hidrau();                         // if you dont need it erase\r\n  }\r\n  \r\n  \r\n}\r\n\r\n\r\n\r\nvoid cerea()   //String \r\n{\r\n   \r\n  cmd.remove(0, 7); // @Cerea; remove\r\n\r\n  int first = cmd.indexOf(';');   // find first ; \r\n  int second = cmd.indexOf(';', first + 1 );  // find second ; suchen\r\n  cmd.remove(0, second + 1); // remove gps speed and minus 1 \r\n\r\n  int ende = cmd.indexOf('END'); //find  \"end\"\r\n  anztb = (ende - 2) / 2; // how many booms\r\n\r\n  teilbreite = cmd.substring(0, ende - 3); //write booms to new string\r\n\r\n \r\n\r\n  int b = 1;\r\n  for (i = 0; i < anztb * 2 ; i = i + 2) { //switch booms\r\n    b = b + 1;\r\n    if (teilbreite.substring(i, i + 1) == \"1\")  digitalWrite(b, LOW);       //boom on\r\n    if (teilbreite.substring(i, i + 1) == \"0\" ) digitalWrite(b, HIGH);      //boom off\r\n  }\r\n\r\n  for (i = anztb + 1 ; i < 8; i++) { //not used booms off\r\n    digitalWrite(i + 1, HIGH);\r\n  }\r\n}\r\n\r\n\r\nvoid hidrau()\r\n{\r\n  int ende = cmd.indexOf('EN'); //serch \"end\"\r\n  cmd.remove(0, ende - 3); // remove rest\r\n  \r\n  \r\n  if (cmd.substring(0, 1) == \"1\") {\r\n   digitalWrite(9, LOW);         //hyro on  \r\n  }\r\n  if (cmd.substring(0, 1) == \"0\") {\r\n    digitalWrite(9, HIGH);       //hyro off\r\n  }\r\n}\r\n\r\n\r\nvoid ser()   // read serial\r\n{\r\n  do {\r\n    if (Serial.available() > 0)\r\n    {\r\n      nextChar = Serial.read();\r\n      if (nextChar >= 32) {\r\n        cmd += nextChar;\r\n      }\r\n    }\r\n  } while (nextChar != 10);  //wait for \r\n\r\n}\r\n"}}
{"actor":{"display_login":"aortner"}}