TestLightDrivenOscillation
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
(a general understanding of what the model is trying to show or explain)
HOW IT WORKS
(what rules the agents use to create the overall behavior of the model)
HOW TO USE IT
(how to use the model, including a description of each of the items in the Interface tab)
THINGS TO NOTICE
(suggested things for the user to notice while running the model)
THINGS TO TRY
(suggested things for the user to try to do (move sliders, switches, etc.) with the model)
EXTENDING THE MODEL
(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)
NETLOGO FEATURES
(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)
RELATED MODELS
(models in the NetLogo Models Library and elsewhere which are of related interest)
CREDITS AND REFERENCES
(a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links)
Comments and Questions
extensions [ gpio ] turtles-own [ velocity acceleration ] globals [ digitals analogs last-level strip gopwm ] to startup setup end to setup ca create-turtles 1 [ set shape "circle" set size 3 set color red set velocity 1 set heading 90] set gopwm true set digitals n-values 19 [ 0 ] set analogs n-values 6 [ 0 ] reset-ticks parse gpio:all-info end to parse [ lists ] set digitals item 0 lists set analogs item 1 lists end to refresh parse gpio:all-info end to-report gpio [ n ] report item n digitals end to-report adc [ n ] report item n analogs end to go every .1 [ refresh ask turtles [ let sgn -1 if xcor > 0 [ set sgn 1 ] set acceleration -1 * light-level * ( sgn ) set velocity velocity + acceleration ] ask turtles [ fd velocity adjust-light abs xcor / max-pxcor ] tick ] end ;;from experiment, i'm getting a range between 120 and 220 for the light meter ;;these values can be chanmged to-report light-level let minv 120 let maxv 220 let val ((adc 4) - minv) / (maxv - minv) if (val > 1) [ report 1 ] if (val < 0) [ report 0 ] report val end to adjust-light [ percent ] let minv 0 let maxv 128 let pwm-level round ( minv + percent * (maxv - minv) ) if (pwm-level != last-level) [ let resp gpio:pwm-set-level (word which-pwm) (word pwm-level) set last-level pwm-level ] end
There is only one version of this model, created over 10 years ago by Corey Brady.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
TestLightDrivenOscillation.png | preview | Preview for 'TestLightDrivenOscillation' | over 10 years ago, by Corey Brady | Download |
This model does not have any ancestors.
This model does not have any descendants.