Forum: Mikrocontroller und Digitale Elektronik CODE from Atmel 328pdef bascom INTO ARDUINO for chip attiny45


von Tomaz S. (tomash)


Lesenswert?

Can Somebody help me to change the code written for chip Atmel 328pdef
in BASCOM to code for chip attiny45 in ARDUINO?

Kindest Regards/Schoene Gruesse und Danke Schoen!

code from Atmel 328pdef bascom INTO chip attiny45 in ARDUINO?


'-----------------------------------------------------------------------
---
'name                     : adc.bas
'copyright                : (c) 1995-2009, MCS Electronics
'purpose                  : demonstrates AD converter
'micro                    : Mega48
'suited for demo          : yes
'commercial addon needed  : no
'-----------------------------------------------------------------------
---

$baud = 19200



'configure single mode and auto prescaler setting
'The single mode must be used with the GETADC() function

'The prescaler divides the internal clock by 2,4,8,16,32,64 or 128
'Because the ADC needs a clock from 50-200 KHz
'The AUTO feature, will select the highest clockrate possible
Config Adc = Single , Prescaler = Auto , Reference = Avcc
'Now give power to the chip
Start Adc

'With STOP ADC, you can remove the power from the chip
'Stop Adc

Dim W As Word , Channel As Byte

Config Portb.5 = Output

Dim X As Integer
Dim Y As Integer
Dim Z As Integer
Dim T As Integer

X = 0
Y = 0
Z = 0

'now read A/D value from channel 0
Do

Z = 0

  W = Getadc(channel)
Print W
  Incr Channel
  If Channel > 0 Then Channel = 0
  Waitms 100


If W > 300 And W < 330 Then
Y = 1

Else

Y = Z
Print Y
End If
If Y = 0 Then
Incr T

Else
T = Z
Print T
End If


If T > 100 Then

X = 1



Portb.5 = 1

Else

Portb.5 = 0

X = Z
End If



Print X
Print Y
Print Z
Print T

Loop
End
Danke und schone Gruesse!

von m.n. (Gast)


Lesenswert?


Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.