Hello @x06
Since setup() runs just once (it is only draw() that loops—you can place random() function in setup. In this case, make sure to round up using ceil(). Then assign that random variable to the segmentCount variable.
Alternately you can use randomSeed() and place that in draw.
See reference for full explanations on randomSeed() and ceil().
Good luck!
BTW, in future posts please format your code. It is difficult to read unformatted…