This i what Visuino has created for me, which i watched a video on utube. If i press the button i with step in one direction. But what im after, when i release the button the stepper will reverse for a certiain amount of steps.
#define VISUINO_ARDUINO_AVR4809
#define VISUINO_ARDUINO_NANO_EVERY
#include <OpenWire.h>
#include <Mitov.h>
#include <Mitov_LogicGates.h>
#include <Mitov_Counter.h>
#include <Mitov_BinaryGenerators.h>
#include <Mitov_Stepper.h>
// Shared Component Member Variables
namespace ComponentVariables
{
class
{
public:
bool Value1 : 1;
uint32_t Value2 : 31;
bool Value3 : 1;
uint32_t Value4 : 4;
bool Value5 : 1;
bool Value6 : 1;
} BitFields;
class Variable1
{
public:
inline static bool GetValue() { return BitFields.Value1; }
inline static void SetValue( bool AValue ) { BitFields.Value1 = AValue; }
};
class Variable2
{
public:
inline static uint32_t GetValue() { return BitFields.Value2; }
inline static void SetValue( uint32_t AValue ) { BitFields.Value2 = AValue; }
};
class Variable3
{
public:
inline static bool GetValue() { return BitFields.Value3; }
inline static void SetValue( bool AValue ) { BitFields.Value3 = AValue; }
};
class Variable4
{
public:
inline static uint32_t GetValue() { return BitFields.Value4; }
inline static void SetValue( uint32_t AValue ) { BitFields.Value4 = AValue; }
};
class Variable5
{
public:
inline static bool GetValue() { return BitFields.Value5; }
inline static void SetValue( bool AValue ) { BitFields.Value5 = AValue; }
};
class Variable6
{
public:
inline static bool GetValue() { return BitFields.Value6; }
inline static void SetValue( bool AValue ) { BitFields.Value6 = AValue; }
};
} // ComponentVariables
// Arduino Constant Declarations
namespace VisuinoConstants
{
class FloatValue0
{
public:
inline static constexpr float GetValue() { return 100; }
};
class FloatValue1
{
public:
inline static constexpr float GetValue() { return 0; }
};
} // VisuinoConstants
// Pin Call Declarations
namespace PinCalls
{
class PinCallerReceive0
{
public:
void Notify( void *_Data );
};
class PinCallerReceive1
{
public:
void Notify( void *_Data );
};
class PinCallerReceive2
{
public:
void Notify( void *_Data );
};
class PinCallerReceive3
{
public:
void Notify( void *_Data );
};
} // PinCalls
// Arduino Board Declarations
namespace BoardDeclarations
{
namespace Types
{
typedef Mitov::ArduinoDigitalOutputChannel<
Mitov::ConstantProperty<22, bool, false >, // IsAnalog
Mitov::ConstantProperty<24, bool, false >, // IsCombinedInOut
Mitov::ConstantProperty<21, bool, false >, // IsOpenDrain
Mitov::ConstantProperty<26, bool, false >, // IsOutput
Mitov::ConstantProperty<20, bool, false >, // IsPullDown
Mitov::ConstantProperty<5, bool, true >, // IsPullUp
Mitov::ConstantProperty<23, bool, false >, // IsRawInput
Mitov::DigitalPin_EmbeddedPinImplementation<6, ::PinCalls::PinCallerReceive0 >, // OutputPin
6 // PIN
ArduinoDigitalChannel_6;
} // Types
namespace Instances
{
Types::ArduinoDigitalChannel_6 ArduinoDigitalChannel_6;
} // Instances
} // BoardDeclarations
// Declarations
namespace Declarations
{
namespace Types
{
typedef Mitov::BooleanInverter<
Mitov::ConstantProperty<4, bool, true >, // Enabled
Mitov::DigitalPin_EmbeddedPinImplementation<3, ::PinCalls::PinCallerReceive1 > // OutputPin
Inverter1;
} // Types
namespace Instances
{
Types::Inverter1 Inverter1;
} // Instances
namespace Types
{
typedef Mitov::UpDownCounter<
Mitov::ConstantProperty<4, bool, true >, // Enabled
Mitov::TypedVariableMinMax<20, int32_t, ::ComponentVariables::Variable2, 0, 2147483647 >, // FCount
Mitov::ConstantProperty<6, int32_t, 1000 >, // InitialValue
Mitov::NestedProperty<14, Mitov::GenericValueLimit<
Mitov::ConstantProperty<13, bool, true >, // RollOver
Mitov::ConstantProperty<12, int32_t, 2147483647 > // Value
> >, // Value_Max
Mitov::NestedProperty<10, Mitov::GenericValueLimit<
Mitov::ConstantProperty<9, bool, false >, // RollOver
Mitov::ConstantProperty<8, int32_t, 0 > // Value
> >, // Value_Min
Mitov::TypedVariable<18, bool, ::ComponentVariables::Variable1 >, // NeedsUpdate
Mitov::TypedPin_EmbeddedPinImplementation<3, ::PinCalls::PinCallerReceive2, int32_t > // OutputPin
UpDownCounter1;
} // Types
namespace Instances
{
Types::UpDownCounter1 UpDownCounter1;
} // Instances
namespace Types
{
typedef Mitov::PulseGenerator<
Mitov::ConstantPropertyFloat<8, float, ::VisuinoConstants::FloatValue1 >, // Asymmetry
Mitov::ConstantProperty<4, bool, true >, // Enabled
Mitov::ConstantPropertyFloat<17, float, ::VisuinoConstants::FloatValue1>, // FPhase
Mitov::TypedVariable<15, bool, ::ComponentVariables::Variable3 >, // FValue
Mitov::ConstantPropertyFloat<7, float, ::VisuinoConstants::FloatValue0 >, // Frequency
Mitov::ConstantProperty<5, bool, false >, // InitialValue
Mitov::DigitalPin_EmbeddedPinImplementation<3, ::PinCalls::PinCallerReceive3 >, // OutputPin
Mitov::ConstantPropertyFloat<9, float, ::VisuinoConstants::FloatValue1 >, // Phase
Mitov::NestedProperty<14, Mitov::TArduinoGeneratorWhenDisabled<
Mitov::ConstantProperty<13, bool, false >, // CompleteCycle
Mitov::ConstantProperty<12, bool, true >, // FCycleCompleted
Mitov::ConstantProperty<11, bool, false > // Reset
> > // WhenDisabled
PulseGenerator1;
} // Types
namespace Instances
{
Types::PulseGenerator1 PulseGenerator1;
} // Instances
namespace Types
{
typedef Mitov::StepperMotor4Wire<
Mitov::ConstantProperty<4, bool, true >, // Enabled
Mitov::ConstantProperty<15, uint32_t, 0 >, // FLastTime
Mitov::TypedVariable<13, uint32_t, ::ComponentVariables::Variable4 >, // FStep
Mitov::ConstantProperty<12, bool, true >, // HalfStep
Mitov::DigitalPin_DirectBoardPinImplementation<8 >, // OutputPins_0
Mitov::DigitalPin_DirectBoardPinImplementation<9 >, // OutputPins_1
Mitov::DigitalPin_DirectBoardPinImplementation<10 >, // OutputPins_2
Mitov::DigitalPin_DirectBoardPinImplementation<11 >, // OutputPins_3
Mitov::ConstantProperty<5, bool, true >, // Reversed
Mitov::ConstantPropertyFloat<6, float, ::VisuinoConstants::FloatValue1 > // StepsPerSecond
Stepper1;
} // Types
namespace Instances
{
Types::Stepper1 Stepper1;
} // Instances
} // Declarations
// Type Converters
namespace TypeConverters
{
Mitov::Convert_BinaryToClock<Mitov::TypedVariable<0, bool, ::ComponentVariables::Variable5 >> Converter0;
Mitov::Convert_BinaryToClock<Mitov::TypedVariable<0, bool, ::ComponentVariables::Variable6 >> Converter1;
} // TypeConverters
// Pin Call Declarations
namespace PinCalls
{
void PinCallerConverterReceive1( void *_Data );
void PinCallerConverterReceive2( void *_Data );
} // PinCalls
// Pin Call Implementations
namespace PinCalls
{
void PinCallerReceive0::Notify( void *_Data )
{
Declarations::Instances::Inverter1.InputPin_o_Receive( _Data );
}
void PinCallerReceive1::Notify( void *_Data )
{
TypeConverters::Converter0.Convert( _Data, PinCallerConverterReceive1 );
}
void PinCallerConverterReceive1( void *_Data )
{
Declarations::Instances::UpDownCounter1.ResetInputPin_o_Receive( _Data );
}
void PinCallerReceive2::Notify( void *_Data )
{
Declarations::Instances::Stepper1.StepInputPin_o_Receive( _Data );
}
void PinCallerReceive3::Notify( void *_Data )
{
TypeConverters::Converter1.Convert( _Data, PinCallerConverterReceive2 );
}
void PinCallerConverterReceive2( void *_Data )
{
Declarations::Instances::UpDownCounter1.DownInputPin_o_Receive( _Data );
}
} // PinCalls
namespace ComponentsHardware
{
void SystemUpdateHardware()
{
}
} // ComponentsHardware
//The setup function is called once at startup of the sketch
void setup()
{
BoardDeclarations::Instances::ArduinoDigitalChannel_6.SystemInit();
Declarations::Instances::UpDownCounter1.SystemInit();
BoardDeclarations::Instances::ArduinoDigitalChannel_6.SystemStart();
Declarations::Instances::UpDownCounter1.SystemStart();
Declarations::Instances::PulseGenerator1.SystemStart();
}
// The loop function is called in an endless loop
void loop()
{
BoardDeclarations::Instances::ArduinoDigitalChannel_6.SystemLoopBegin();
Declarations::Instances::PulseGenerator1.SystemLoopBegin();
}