Sorry if it looks like spam but I'm still having some issues. I wrote the following code to make a sensor send a message over Sigfox, the thing is I wanted to use a PWM instead of a RiseEvent, I believe I'm wasting a lot of power doing this.
Define PinMode Pin0 As AnalogRead
Class AnalogRead
Shared Event GetPin1Analog() RaiseEvent Every 4 Seconds
Dim value As Short
value = Pin0 // Read the pin. This activates the ADC
'Return value // Return value in millivolts
Led2 = True
Thread.Sleep(value)
Led2 = False
If value > 1600 Then
Led3 = True
Dim sfData As ListOfByte = New ListOfByte
'Add data to Sigfox message (up to 12 bytes)
sfData.Add(0x40)
sfData.Add(0x87)
sfData.Add(0x1a)
sfData.Add(0x54)
Lplan.SigfoxRadioZone(SigfoxRadioZone.FCC_US)
Lplan.Sigfox(sfData)
Led3 = False
End If
End Event
End Class
It works fine, the issue is using the Pwm as a Pin mode.
Therefore, I can't run this sample either:
01 Define PinMode Pin0 As PwmOutput
02
03 Public Sub SetPwm()
04 Dim pwm1kHz As Pwm
05 pwm1kHz = Pwm.Create(1000) // create PWM with 1000µs period
06 pwm1kHz.SetDutyCycle(Pin0, 200) // set PWM to 20% duty cycle on Pin0
07 pwm1kHz.Start() // start PWM
08 End Sub
Also, I went through McScript but I don't totally get how to convert the Short (string values would help too) value to bytes, I'd appreciate any reference for this. Thanks in advance!