TestLightDrivenOscillation
Model was written in NetLogo 5.0
•
Viewed 172 times
•
Downloaded 20 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
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 almost 10 years ago by Corey Brady.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
TestLightDrivenOscillation.png | preview | Preview for 'TestLightDrivenOscillation' | almost 10 years ago, by Corey Brady | Download |
This model does not have any ancestors.
This model does not have any descendants.