turning off analog Read

I am running a program that changes matrix shapes based on the position of a potentiometer when a switch is high. I am using analogRead to get values from the pot. The problem is that I want to stop reading from the pot when the switch is flipped LOW. Is there a way to shut off my analogRead?

Hi cloe, the analog read is only 'on' when you call the function analogRead(). If you don't call the funciton, it won't read.

if(digitalRead(swPin) == HIGH){
val = analogRead(potPin); // this will only read when the pin is HIGH