{
  "Config": {
    "Build": {
      "Board": "arduino:avr:uno"
    }
  },
  "Version": "2",
  "Product": "Visuino Pro - Visual Arduino Programming",
  "Content": "OpenWire Diagram",
  "Units": [
    {
      "Name": "__OpenWireRootUnit__",
      "*": [
        {
          "X": 976,
          "Name": "Arduino",
          "Instance": {
            "Serial": {
              "*": [
                {
                  "+": "TArduinoHardwareSerial"
                }
              ]
            },
            "+": "TArduinoBoard",
            "Modules": {
              "*": [
                {
                  "+": "TArduinoEEPROMModule"
                },
                {
                  "+": "TArduinoWatchdogTimerModule"
                },
                {
                  "+": "TArduinoProcessor328Module"
                }
              ]
            },
            "I2CChannels": {
              "*": [
                {
                  "+": "TArduinoI2C"
                }
              ]
            },
            "Digital": {
              "*": [
                {
                  "+": "TArduinoAdditionalDigitalSerial0Channel"
                },
                {
                  "+": "TArduinoAdditionalDigitalSerial0Channel"
                },
                {
                  "+": "TArduinoAdditionalDigitalInterruptChannel"
                },
                {
                  "+": "TArduinoBasicDigitalPWMInterruptChannel"
                },
                {
                  "+": "TArduinoAdditionalDigitalChannel"
                },
                {
                  "+": "TArduinoBasicDigitalPWMChannel"
                },
                {
                  "+": "TArduinoBasicDigitalPWMChannel"
                },
                {
                  "+": "TArduinoAdditionalDigitalChannel"
                },
                {
                  "+": "TArduinoAdditionalDigitalChannel"
                },
                {
                  "+": "TArduinoBasicDigitalPWMChannel"
                },
                {
                  "+": "TArduinoBasicDigitalPWMChannel"
                },
                {
                  "+": "TArduinoBasicDigitalPWMSPI0Channel"
                },
                {
                  "+": "TArduinoAdditionalDigitalSPI0Channel"
                },
                {
                  "+": "TArduinoAdditionalDigitalSPI0Channel"
                },
                {
                  "+": "TArduinoCombinedAnalogDigitalChannel"
                },
                {
                  "+": "TArduinoCombinedAnalogDigitalChannel"
                },
                {
                  "+": "TArduinoCombinedAnalogDigitalChannel"
                },
                {
                  "+": "TArduinoCombinedAnalogDigitalChannel"
                },
                {
                  "+": "TArduinoCombinedAnalogDigitalI2C0Channel"
                },
                {
                  "+": "TArduinoCombinedAnalogDigitalI2C0Channel"
                }
              ]
            },
            "SPIChannels": {
              "*": [
                {
                  "+": "TArduinoSPI"
                }
              ]
            },
            "BoardType": "Arduino Uno"
          },
          "Type": "Component",
          "Y": 256
        },
        {
          "X": 608,
          "Name": "CustomCode1",
          "Instance": {
            "+": "TArduinoCustomCode",
            "OnExecute": "stepper.processMovement();  \r\nstepper.setSpeedInStepsPerSecond(Speed);\r\nstepper.setAccelerationInStepsPerSecondPerSecond(AccelSpeed);\r\n\r\n\r\n   long currentPosition = stepper.getCurrentPositionInSteps();\r\n   StepsDone1.Send(currentPosition);\r\n   CurrentSpeed1.Send(Speed);\r\n\r\nstepper.setAccelerationInStepsPerSecondPerSecond(AccelSpeed);\r\n\r\n\r\nstepper.processMovement();\r\n  if(!stepper.motionComplete())\r\n{bool Finished = false;\r\n Finished1.Send(Finished);\r\n}\r\nelse\r\n{\r\nbool Finished = true;\r\n  \r\nFinished1.Send(Finished);\r\n}",
            "GlobalDeclarations": "FlexyStepper stepper;",
            "OnStart": "stepper.setAccelerationInRevolutionsPerSecondPerSecond(100);",
            "OnInit": "\r\npinMode(LED_PIN, OUTPUT);   \r\npinMode(STOP_BUTTON_PIN, INPUT_PULLUP);\r\n\r\nstepper.connectToPins(MOTOR_STEP_PIN, MOTOR_DIRECTION_PIN);\r\n\r\nbool stopFlag = false;\r\nbool Finished = false;\r\nstepper.setStepsPerRevolution(400);\r\n\r\nstepper.setAccelerationInStepsPerSecondPerSecond(AccelSpeed);",
            "Inputs": {
              "*": [
                {
                  "Name": "Steps1",
                  "OnData": "TotalSteps = AValue;",
                  "+": "TArduinoCustomCodeInputIntegerElement",
                  "InputPin": {
                    "SourcePin": {
                      "ID": "__OpenWireRootUnit__.IntegerValue1.OutputPin"
                    }
                  }
                },
                {
                  "Name": "Speed1",
                  "OnData": "Speed = AValue;\r\n",
                  "+": "TArduinoCustomCodeInputIntegerElement",
                  "InputPin": {
                    "SourcePin": {
                      "ID": "__OpenWireRootUnit__.IntegerValue2.OutputPin"
                    }
                  }
                },
                {
                  "Name": "AccelSpeed1",
                  "OnData": "AccelSpeed = AValue;",
                  "+": "TArduinoCustomCodeInputIntegerElement",
                  "InputPin": {
                    "SourcePin": {
                      "ID": "__OpenWireRootUnit__.IntegerValue3.OutputPin"
                    }
                  }
                },
                {
                  "Name": "Start1",
                  "OnData": "stepper.setCurrentPositionInSteps(0);\r\nstepper.setTargetPositionInSteps(TotalSteps);\r\n\r\nstepper.setSpeedInStepsPerSecond(Speed);\r\nstepper.processMovement();",
                  "+": "TArduinoCustomCodeInputClockElement",
                  "InputPin": {
                    "SourcePins": [
                      {
                        "ID": "__OpenWireRootUnit__.Start1.OutputPin"
                      }
                    ]
                  }
                },
                {
                  "Name": "Stop1",
                  "OnData": "stepper.setTargetPositionToStop();",
                  "+": "TArduinoCustomCodeInputClockElement"
                }
              ]
            },
            "Outputs": {
              "*": [
                {
                  "Name": "StepsDone1",
                  "+": "TArduinoCustomCodeOutputIntegerElement"
                },
                {
                  "Name": "CurrentSpeed1",
                  "+": "TArduinoCustomCodeOutputIntegerElement"
                },
                {
                  "Name": "Finished1",
                  "+": "TArduinoCustomCodeOutputDigitalElement"
                }
              ]
            },
            "Includes": "#include <FlexyStepper.h>\r\n",
            "Defines": "const int LED_PIN = 13;\r\nconst int MOTOR_STEP_PIN = 2;\r\nconst int MOTOR_DIRECTION_PIN = 3;\r\nconst int STOP_BUTTON_PIN = 9;\r\n\r\nint32_t TotalSteps;\r\nint32_t Speed;\r\nint32_t AccelSpeed;\r\n"
          },
          "Type": "Component",
          "Y": 320
        },
        {
          "X": 256,
          "Name": "IntegerValue1",
          "Instance": {
            "Value": 10000,
            "OutputPin": {
              "SinkPins": [
                {
                  "Name": "__OpenWireRootUnit__.CustomCode1.Inputs.Integer.InputPin",
                  "ID": "__OpenWireRootUnit__.CustomCode1.Inputs._Item0.InputPin"
                }
              ]
            },
            "+": "TArduinoIntegerValue"
          },
          "Type": "Component",
          "Y": 352
        },
        {
          "X": 272,
          "Name": "Start1",
          "Instance": {
            "OutputPin": {
              "SinkPins": [
                {
                  "Name": "__OpenWireRootUnit__.CustomCode1.Inputs.Start1.InputPin",
                  "ID": "__OpenWireRootUnit__.CustomCode1.Inputs._Item3.InputPin"
                }
              ]
            },
            "+": "TArduinoStart"
          },
          "Type": "Component",
          "Y": 560
        },
        {
          "X": 256,
          "Name": "IntegerValue3",
          "Instance": {
            "Value": 100,
            "OutputPin": {
              "SinkPins": [
                {
                  "Name": "__OpenWireRootUnit__.CustomCode1.Inputs.Integer.InputPin",
                  "ID": "__OpenWireRootUnit__.CustomCode1.Inputs._Item2.InputPin"
                }
              ]
            },
            "+": "TArduinoIntegerValue"
          },
          "Type": "Component",
          "Y": 480
        },
        {
          "X": 256,
          "Name": "IntegerValue2",
          "Instance": {
            "Value": 1200,
            "OutputPin": {
              "SinkPins": [
                {
                  "Name": "__OpenWireRootUnit__.CustomCode1.Inputs.Integer.InputPin",
                  "ID": "__OpenWireRootUnit__.CustomCode1.Inputs._Item1.InputPin"
                }
              ]
            },
            "+": "TArduinoIntegerValue"
          },
          "Type": "Component",
          "Y": 416
        }
      ],
      "Type": "Diagram",
      "Selection": [
        "IntegerValue1"
      ]
    }
  ]
}
